Exemplo n.º 1
0
        public async Task <IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
        {
            var result = await _userEngine.ExterLogin();

            if (!result.Succeeded)
            {
                if (result.IsLockedOut)
                {
                    return(StatusCode(403, new { message = "User account locked out." }));
                }

                if (result.RequiresTwoFactor)
                {
                    return(BadRequest(new { message = "User account locked out." }));
                }

                result = await _userEngine.CreateExterLoginUser(new ExterLoginConfirmModel()
                {
                    Email = result.Email
                });

                if (!result.Succeeded)
                {
                    if (result.IsLockedOut)
                    {
                        return(StatusCode(403, new { message = "User account locked out." }));
                    }

                    return(BadRequest(new { message = result.StatusMessage }));
                }
            }

            var token = CreateToken(result.Id);

            return(Redirect(returnUrl + "?token=" + token));
        }