public static Response SignIn(this NancyModule module, ChatUser user) { var claims = new List <Claim>(); claims.Add(new Claim(JabbRClaimTypes.Identifier, user.Id)); // Add the admin claim if the user is an Administrator if (user.IsAdmin) { claims.Add(new Claim(JabbRClaimTypes.Admin, "true")); } return(module.SignIn(claims)); }
public dynamic Process(NancyModule nancyModule, AuthenticateCallbackData model) { Response response; if (model.ReturnUrl != null) { response = nancyModule.Response.AsRedirect("~" + model.ReturnUrl); } else { response = nancyModule.AsRedirectQueryStringOrDefault("~/"); if (nancyModule.IsAuthenticated()) { response = nancyModule.AsRedirectQueryStringOrDefault("~/account/#identityProviders"); } } if (model.Exception != null) { nancyModule.Request.AddAlertMessage("error", model.Exception.Message); } else { UserInformation information = model.AuthenticatedClient.UserInformation; var claims = new List <Claim>(); claims.Add(new Claim(ClaimTypes.NameIdentifier, information.Id)); claims.Add(new Claim(ClaimTypes.AuthenticationMethod, model.AuthenticatedClient.ProviderName)); if (!String.IsNullOrEmpty(information.UserName)) { claims.Add(new Claim(ClaimTypes.Name, information.UserName)); } if (!String.IsNullOrEmpty(information.Email)) { claims.Add(new Claim(ClaimTypes.Email, information.Email)); } nancyModule.SignIn(claims); } return(response); }