public async Task <IActionResult> Authorize(OpenIdConnectRequest request) { if (!User.Identity.IsAuthenticated) { // If the client application request promptless authentication, // return an error indicating that the user is not logged in. if (request.HasPrompt(OpenIdConnectConstants.Prompts.None)) { var properties = new AuthenticationProperties(new Dictionary <string, string> { [OpenIdConnectConstants.Properties.Error] = OpenIdConnectConstants.Errors.LoginRequired, [OpenIdConnectConstants.Properties.ErrorDescription] = "The user is not logged in." }); // Ask OpenIddict to return a login_required error to the client application. return(Forbid(properties, OpenIdConnectServerDefaults.AuthenticationScheme)); } return(Challenge()); } // Retrieve the profile of the logged in user. var user = await _userManager.GetUserAsync(User); if (user == null) { return(_notice.Error(this, OpenIdConnectConstants.Errors.ServerError)); } // Create a new authentication ticket. var ticket = await CreateTicketAsync(request, user); // Returning a SignInResult will ask OpenIddict to issue the appropriate access/identity tokens. return(SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme)); }
public async Task <IActionResult> EditUserInfo() { var user = await _userManager.GetUserAsync(User); if (user == null) { await _signInManager.SignOutAsync(); return(_notice.Error(this)); } var model = new EditUserInfoViewModel { UserName = user.UserName, Logins = await _userManager.GetLoginsAsync(user), Email = user.Email, EmailConfirmed = user.EmailConfirmed, FullName = user.FullName, NickName = user.NickName }; return(View(model)); }
public async Task <IActionResult> EditUserInfo() { var user = await _userManager.GetUserAsync(User); if (user == null) { await _signInManager.SignOutAsync(); return(_notice.Error(this)); } var model = new EditUserInfoViewModel { UserName = user.UserName, Logins = await _userManager.GetLoginsAsync(user), Email = user.Email, EmailConfirmed = user.EmailConfirmed, FullName = user.FullName, FavColor = user.FavColor // !! ADDING FIELDS: If you want users to be able to edit field }; return(View(model)); }