public PasswordDontMatch() { var app = new Application("*****@*****.**", "password", "password"); new Registrator().ApplyForMembership(app); _result = new Authenticator().AuthenticateUser(new Credentials { Email = "*****@*****.**", Password = "******" }); }
public ValidTokenLogin() { //register the new user... var app = new Application("*****@*****.**", "password", "password"); var result = new Registrator().ApplyForMembership(app); var auth = new Authenticator(); _result = auth.AuthenticateUserByToken(result.NewUser.AuthenticationToken.ToString()); }
public ValidLogin() { //register the new user... var app = new Application("*****@*****.**", "password", "password"); new Registrator().ApplyForMembership(app); var auth = new Authenticator(); _result = auth.AuthenticateUser(new Credentials { Email = "*****@*****.**", Password = "******" }); }
public AuthenticationResult AuthenticateUser(Credentials creds) { _session = new Session(); var result = new AuthenticationResult(); User user = null; this.CurrentCredentials = creds; if (EmailOrPasswordNotPresent()) { result = InvalidLogin(Properties.Resources.EmailOrPasswordMissing); } else { //find the user user = LocateUser(); //if they're not here, we're done if (user == null) { result = InvalidLogin(Properties.Resources.InvalidLogin); //does the password match? } else if (HashedPasswordDoesNotMatch(user)) { result = InvalidLogin(Properties.Resources.InvalidLogin); //success } else { //success! user.AddLogEntry("Login", "User logged in"); result.Session = CreateSession(user); SetUserLoginStats(user); //save changes UserAuthenticated(user); result.Authenticated = true; result.User = user; result.Message = Properties.Resources.UserAuthenticated; _session.SaveChanges(); } } //dispose of this _session.Dispose(); return result; }
public EmailNotFound() { _result = new Authenticator().AuthenticateUser(new Credentials { Email = "*****@*****.**", Password = "******" }); }
public AuthenticationResult AuthenticateUserByToken(string token, string ip = "127.0.0.1") { var result = new AuthenticationResult(); _session = new Session(); if (String.IsNullOrWhiteSpace(token)) { result = InvalidLogin("No token provided"); } else { this.CurrentCredentials = new Credentials { Token = Guid.Parse(token), IP = ip }; var user = FindUserByAuthenticationToken(); if (user == null) { result = InvalidLogin("Invalid token"); } else { //success user.AddLogEntry("Login", "User logged in by token"); result.Session = CreateSession(user); SetUserLoginStats(user); UserAuthenticated(user); result.Authenticated = true; result.User = user; result.Message = Properties.Resources.UserAuthenticated; _session.SaveChanges(); } } _session.Dispose(); return result; }
public EmptyPassword() { _result = new Authenticator().AuthenticateUser(new Credentials { Email = "*****@*****.**", Password="" }); }
public EmptyEmail() { _result = new Authenticator().AuthenticateUser(new Credentials { Email = "" }); }