         }
     }
     
-    public func join(to teamID: String) -> Completable {
+    public func join(to teamID: String, as memberName: String) -> Completable {
         guard let currentUser = Auth.auth().currentUser else {
             return Completable.error(TeamRepositoryError.notAuthenticated)
         }
-
         let memberID = currentUser.uid
-        let memberName = currentUser.displayName ?? "no name"   // FIXME:
         
         return team(for: teamID)
             .take(1)

public enum TeamRepositoryError: Error {
    case notAuthenticated
    case teamNotFound
}

public protocol TeamRepository {

            return Disposables.create()
        }
    }
    
    public func changeMemberName(_ memberName: String, in teamID: String) -> Completable {
        guard let currentUser = Auth.auth().currentUser else {
            return Completable.error(TeamRepositoryError.notAuthenticated)
        }
        let memberID = currentUser.uid

        return Completable.create { observer in
            let memberRef = Database.database().reference().child("team_members").child(teamID).child(memberID)
            memberRef.observeSingleEvent(of: .value, with: { snapshot in
                if !snapshot.exists() {
                    observer(.error(TeamRepositoryError.notInTeam))
                } else {
                    memberRef.setValue(memberName) { (error, _) in
                        if let error = error {
                            observer(.error(error))
                        } else {
                            observer(.completed)
                        }
                    }
                }
            }, withCancel: { error in
                observer(.error(error))
            })
            return Disposables.create()
        }
    }
}
