public string Authenticate(string email, string password) { var query = new Query.Users(); var encrypted = query.GetPassword(email); if (!DecryptPassword(email, password, encrypted)) { return(Error()); } { //password verified by Bcrypt var user = query.AuthenticateUser(email, encrypted); if (user != null) { User.LogIn(user.userId, user.email, user.name, user.datecreated, "", 1, user.photo); User.Save(true); if (user.lastboard == 0) { return("boards"); } return("board/" + user.lastboard + "/" + user.lastboardName.Replace(" ", "-").ToLower()); } } return(Error("Incorrect email and/or password")); }
public string Authenticate(string email, string password) { //var sqlUser = new SqlQueries.User(S); var query = new Query.Users(S.Server.sqlConnectionString); var encrypted = query.GetPassword(email); if (!DecryptPassword(email, password, encrypted)) { return(Error()); } { //password verified by Bcrypt var user = query.AuthenticateUser(email, encrypted); if (user != null) { S.User.userId = user.userId; S.User.userType = user.usertype; S.User.email = email; S.User.photo = user.photo; S.User.name = user.name; S.User.datecreated = user.datecreated; S.User.saveSession = true; return(Success()); } } return(Error()); }