Ejemplo n.º 1
0
 public UserDto Login(LoginRequest request)
 {
     var result = new UserDto();
     if (request.recentPsyauth.IsntEmpty()) {
         return InnerPsyauthLogin(request.recentPsyauth);
     }
     else if (request.password.IsntEmpty() && request.username.IsntEmpty()) {
         if (request.username.ToLower() == Auth.VISITOR_USERNAME && request.password == Auth.VISITOR_PASSWORD) {
             result = RegisterUser(new RegisterUserRequest() {
                 username = "******",
                 psychlotron = "[None]",
                 firstName = "Visitor",
                 lastName = "V",
                 email = "*****@*****.**",
                 password = Auth.VISITOR_PASSWORD
             });
         }
         else {
             result = InnerLogin(request.username, request.password);
         }
     }
     return result;
 }
Ejemplo n.º 2
0
 private UserDto InnerPsyauthLogin(string psyauth)
 {
     var result = new UserDto();
     var userId = Auth.Psyauthenticate(psyauth);
     if (userId.IsValidId()) {
         using (var dc = new PsyDc()) {
             var user = dc.Users.SingleOrDefault(u => u.UserId.Equals(userId));
             if (user != null) {
                 result = user.ToDto();
                 result.success = true;
                 result.psyauth = psyauth;
             }
         }
     }
     return result;
 }
Ejemplo n.º 3
0
 private UserDto InnerLogin(string username, string password)
 {
     var result = new UserDto();
     using (var dc = new PsyDc()) {
         var user = dc.Users.SingleOrDefault(u => u.Username.ToLower() == username.ToLower());
         if (user != null) {
             if (Auth.VerifyPassword(user.UserId, password)) {
                 result = user.ToDto();
                 result.success = true;
                 result.psyauth = Auth.NewPsyauth(user).ToString();
             }
         }
     }
     return result;
 }