コード例 #1
0
ファイル: IsAdmin.cs プロジェクト: Delbert93/PSF
        public IActionResult LoginValidation(TaintedUserModel taintedUser)
        {
            UserModel userModel = new UserBuilder()
                                  .UseName(taintedUser.Username)
                                  .UsePassword(taintedUser.Password)
                                  .Build();

            if (userModel.isValidUser == true)
            {
                if (DBUserInfoLoginValidation(userModel))
                {
                    //tell UI "Login Successful;
                    UserSnapshot userSnapshot = new UserSnapshot(userModel.getUsername())
                    {
                        gameCredit = userModel.getGameCredit()
                    };

                    return(Ok());
                }
                else
                {
                    //tell the UI "Invalid Username or Password"
                    return(BadRequest());
                }
            }
            else
            {
                //tell the UI "Invalid Username or Password"
                return(BadRequest());
            }
        }
コード例 #2
0
ファイル: IsAdmin.cs プロジェクト: Delbert93/PSF
        public async Task <IActionResult> AdminRegistration(TaintedUserModel taintedUser)
        {
            UserModel userModel = new UserBuilder()
                                  .UseName(taintedUser.Username)
                                  .UsePassword(taintedUser.Password)
                                  .UseEmail(taintedUser.Email)
                                  .Build();

            if (userModel.isValidUser == true)
            {
                //tell UI "Login Successful;
                Admin admin = new Admin();
                admin.Username = userModel.getUsername();
                admin.Password = userModel.getPassword();
                admin.Email    = userModel.getEmail();
                Random rnd     = new Random();
                int    randKey = rnd.Next(1000000, 2000000000);
                admin.Key = userModel.HashKey(randKey.ToString());
                await repository.CreateAdminAsync(admin);

                return(Ok());
            }
            else
            {
                //tell the UI "Invalid Username or Password"
                return(BadRequest());
            }
        }
コード例 #3
0
        public async Task <IActionResult> RegistrationValidation(TaintedUserModel taintedUser)
        {
            UserModel userModel = new UserBuilder()
                                  .UseName(taintedUser.Username)
                                  .UsePassword(taintedUser.Password)
                                  .UseEmail(taintedUser.Email)
                                  .Build();

            if (userModel.isValidUser == true)
            {
                //tell UI "Login Successful;
                UserDTO userDTO = new UserDTO();
                userDTO.Username = userModel.getUsername();
                //userDTO.Password = userModel.HashPassword(userModel.getPassword());
                //This is causing the password to get hashed twice. Did we want this or was it something we didnt relize was going on. Removed it for now so I dont have to hash the login twice.
                userDTO.Password   = userModel.getPassword();
                userDTO.Email      = userModel.getEmail();
                userDTO.GameCredit = userModel.getGameCredit();
                await repository.CreateUserAsync(userDTO);

                Log.Information("User " + userModel.getUsername() + " Has been created successfully");
                return(Ok());
            }
            else
            {
                //tell the UI "Invalid Username or Password"
                return(BadRequest());
            }
        }
コード例 #4
0
        public async Task <bool> AdminValidateLogin(TaintedUserModel taintedUser)
        {
            var response = await client.PostAsJsonAsync("admin/IsAdmin/LoginValidation", taintedUser);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        public async Task <bool> ValidateRegistration(TaintedUserModel taintedUser)
        {
            var response = await client.PostAsJsonAsync("api/Registration/RegistrationValidation", taintedUser);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: LoginController.cs プロジェクト: Delbert93/PSF
        public async Task <IActionResult> LoginValidation(TaintedUserModel taintedUser)
        {
            UserModel userModel = new UserBuilder()
                                  .UseName(taintedUser.Username)
                                  .UsePassword(taintedUser.Password)
                                  .Build();

            if (userModel.isValidUser == true)
            {
                if (DBUserInfoLoginValidation(userModel))
                {
                    //tell UI "Login Successful;
                    UserSnapshot userSnapshot = new UserSnapshot(userModel.getUsername())
                    {
                        gameCredit = userModel.getGameCredit()
                    };

                    HttpContext.Session.SetString("sessionId", Guid.NewGuid().ToString());


                    //tell UI "Login Successful;
                    UserDTO userDTO = new UserDTO();
                    userDTO.Username = userModel.getUsername();
                    //userDTO.Password = userModel.HashPassword(userModel.getPassword());
                    //This is causing the password to get hashed twice. Did we want this or was it something we didnt relize was going on. Removed it for now so I dont have to hash the login twice.
                    userDTO.Password   = userModel.getPassword();
                    userDTO.Email      = userModel.getEmail();
                    userDTO.GameCredit = userModel.getGameCredit();

                    var sessionString = Guid.NewGuid().ToString();
                    await repository.AssignSessionIdToUserAsync(userDTO.Id, sessionString);

                    Log.Information("User " + userModel.getUsername() + " Has logged in successfully");
                    return(Ok());
                }
                else
                {
                    //tell the UI "Invalid Username or Password"
                    return(BadRequest());
                }
            }
            else
            {
                //tell the UI "Invalid Username or Password"
                return(BadRequest());
            }
        }