/// <summary> /// Deal with an already known social identity /// </summary> private dynamic HandleKnownIdentity(UserIdentity userIdentity, INancyModule nancyModule, string returnUrl) { // Get the currently logged in user var loggedInUser = GetLoggedInUser(nancyModule); // If we aren't logged in, log ourselves in if (loggedInUser == null) { User user = null;//ReadStore.Users.FindAllByUserId(userIdentity.UserId).FirstOrDefault(); if (user == null) { // Something went wrong //nancyModule.AddAlertMessage(); return(nancyModule.AsRedirectQueryStringOrDefault("~/dashboard")); } nancyModule.SignIn(user); return(string.IsNullOrWhiteSpace(returnUrl) ? nancyModule.AsRedirectQueryStringOrDefault("~/dashboard") : nancyModule.Response.AsRedirect(returnUrl)); } // If we are logged in, we are trying to link ourselves, check if we are allowed //if (loggedInUser.UserId != userIdentity.UserId) //{ // // You can't link an account that's already attached to another user // // TODO: Implement // //nancyModule.AddAlertMessage("error", string.Format("This {0} account has already been linked to another user.", providerName)); //} // We are logged in, and are trying to link ourselves to something that has already been linked, just redirect // TODO: Perhaps we should update the returned data at this time return(nancyModule.Response.AsRedirect("~/account/identity")); }
public static Response SignIn(this INancyModule module, User user, bool isPersistent = false) { var claims = new List <Claim> { new Claim(TheBenchClaimTypes.Email, user.Email), new Claim(TheBenchClaimTypes.Name, user.DisplayName) }; return(module.SignIn(claims, isPersistent)); }
/// <summary> /// Deal with an already known social identity /// </summary> private dynamic HandleKnownIdentity(UserIdentity userIdentity, INancyModule nancyModule, string returnUrl) { // Get the currently logged in user var loggedInUser = GetLoggedInUser(nancyModule); // If we aren't logged in, log ourselves in if (loggedInUser == null) { User user = null;//ReadStore.Users.FindAllByUserId(userIdentity.UserId).FirstOrDefault(); if (user == null) { // Something went wrong //nancyModule.AddAlertMessage(); return nancyModule.AsRedirectQueryStringOrDefault("~/dashboard"); } nancyModule.SignIn(user); return string.IsNullOrWhiteSpace(returnUrl) ? nancyModule.AsRedirectQueryStringOrDefault("~/dashboard") : nancyModule.Response.AsRedirect(returnUrl); } // If we are logged in, we are trying to link ourselves, check if we are allowed //if (loggedInUser.UserId != userIdentity.UserId) //{ // // You can't link an account that's already attached to another user // // TODO: Implement // //nancyModule.AddAlertMessage("error", string.Format("This {0} account has already been linked to another user.", providerName)); //} // We are logged in, and are trying to link ourselves to something that has already been linked, just redirect // TODO: Perhaps we should update the returned data at this time return nancyModule.Response.AsRedirect("~/account/identity"); }