/////////////////////////////////////////////////////////////////////// ///////////////////////// PUBLIC/API METHODS ////////////////////////// /////////////////////////////////////////////////////////////////////// #region Login / Register /* * Returns 0 upon success * Error codes: * (-1) - database error * (1) - invalid nickname * (2) - invalid real name * (3) - invalid password * (4) - nickname already exists */ public override int Register(string nickname, string realName, string password) { if (nickname.Length < 1) { return(1); } if (realName.Length < 1) { return(2); } if (password.Length < 1) { return(3); } if (DBController.UserExists(conn, nickname)) { return(4); } if (!DBController.CreateUser(conn, nickname, realName, password)) { return(-1); } return(0); }
public override int Register(string nickname, string realName, string password) { //Invalid Nickname inserted if (nickname.Length < 1) { return(1); } //Invalid Name inserted if (realName.Length < 1) { return(2); } //Invalid Password inserted if (password.Length < 1) { return(3); } //Nickname chosen already exists if (DBController.UserExists(connection, nickname)) { return(4); } //Error during the connection with the database if (!DBController.CreateUser(connection, nickname, realName, password)) { return(-1); } //No error during the registration return(0); }