public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { this._userManager = context.OwinContext.GetUserManager <ApplicationUserService>(); ApplicationUser user = await _userManager.FindAsync(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "User name sau parola invalida"); return; } if (!user.EmailConfirmed) { context.SetError("account_unconfirmed", "Contul nu a fost confirmat"); return; } ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(_userManager, "JWT"); var ticket = new AuthenticationTicket(oAuthIdentity, null); context.Validated(ticket); }