private async Task <AuthenticatedUser> AssociateCredential(AuthenticatedUser user) { var result = await AuthService.ReadExternalLoginCredential(OwinContext); if (result.ExternalIdentity == null) { // User got here without an external login cookie (or an expired one) // Send them to the logon action return(null); } await AuthService.AddCredential(user.User, result.Credential); // Notify the user of the change MessageService.SendCredentialAddedNotice(user.User, result.Credential); return(new AuthenticatedUser(user.User, result.Credential)); }