src/main/java/com/webcheckers/appl/PlayerLobby.java
/**
     * Signs in a given user with username and password. Checks if username
     * and password are both valid and then adds them to the user table. Signs in
     * user if they have previously signed in, or creates a new account.
     * @return INVALID_USER_FORMAT if the username is invalid
     * @return INVALID_PASS_FORMAT if the password is invalid
     * @return NEW_USER_LOGIN if the user/pass combination is valid and it is a new user
     * @return USER_ALREADY_LOGIN if the user/pass combination is already logged in
     * @return EXISTING_USER_LOGIN if the user/pass combination is not logged in 
     * @return WRONG_PASS_OR_USER_EXISTS if wrong password or user already exists
     */
Signs in a given user with username and password. Checks if username
and password are both valid and then adds them to the user table. Signs in
user if they have previously signed in, or creates a new account.
Signs in a given user with username and password . Checks if username and password are both valid and then adds them to the user table . Signs in user if they have previously signed in or creates a new account .
public LoginStatus sign_in(String username, String password){
        if (!check_name(username)) {
            return LoginStatus.INVALID_USER_FORMAT;
        } if (Users.get(username) == null) {
            if (!check_pass(password)) {
                return LoginStatus.INVALID_PASS_FORMAT;
            }
            Users.put(username, password);
            Player player = new Player(username);
            Players.put(username, player);
            this.num_logged_in++;
            return LoginStatus.NEW_USER_LOGIN;
        } else {
            if(Users.get(username).equals(password)) {
                if (Players.get(username).isLogged()) {
                    return LoginStatus.USER_ALREADY_LOGIN;
                }
                Players.get(username).login();
                this.num_logged_in++;
                return LoginStatus.EXISTING_USER_LOGIN;
            }
        }
        return LoginStatus.WRONG_PASS_OR_USER_EXISTS;
    }
public LoginStatus sign_in ( String username , String password ) { if ( ! check_name ( username ) ) { return LoginStatus . INVALID_USER_FORMAT ; } if ( Users . get ( username ) == null ) { if ( ! check_pass ( password ) ) { return LoginStatus . INVALID_PASS_FORMAT ; } Users . put ( username , password ) ; Player player = new Player ( username ) ; Players . put ( username , player ) ; this . num_logged_in ++ ; return LoginStatus . NEW_USER_LOGIN ; } else { if ( Users . get ( username ) . equals ( password ) ) { if ( Players . get ( username ) . isLogged ( ) ) { return LoginStatus . USER_ALREADY_LOGIN ; } Players . get ( username ) . login ( ) ; this . num_logged_in ++ ; return LoginStatus . EXISTING_USER_LOGIN ; } } return LoginStatus . WRONG_PASS_OR_USER_EXISTS ; }
Signs in a given user with username and password.
Signs in a given user with username and password .