Ejemplo n.º 1
0
        public async Task <IActionResult> Login(LoginParameters parameters)
        {
            var authenticationContext = await _accountProxy.Authenticate(new AuthenticationParameters
            {
                AreaCode   = parameters.AreaCode,
                Identifier = parameters.MobileNumber,
                Password   = _protectionService.ComputeHash(parameters.Password),
                Type       = UserType.Client
            });

            if (authenticationContext != null)
            {
                if (!authenticationContext.RequiredMethods.Any())
                {
                    var token = await _accountProxy.GenerateToken(authenticationContext);

                    if (string.IsNullOrWhiteSpace(token))
                    {
                        TempData["errorMessage"] = "Something went wrong, please try again.";
                        return(View());
                    }

                    var options = new CookieOptions {
                        Expires = DateTime.Now.AddMinutes(30)
                    };
                    Response.Cookies.Append("Token", token, options);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            TempData["errorMessage"] = "Your email or password is wrong, please try again";
            return(View());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Login(LoginParameters loginParameters)
        {
            var authenticationContext = await _accountProxy.Authenticate(new AuthenticationParameters
            {
                Identifier = loginParameters.MobileNumber,
                AreaCode   = loginParameters.AreaCode,
                Type       = UserType.Staff
            });

            if (authenticationContext != null)
            {
                return(RedirectToAction("Authentication", "Biometrics", authenticationContext));
            }
            return(View());
        }