void provider_BeginRequest(object sender, PowerSchoolEventArgs e) { // Remember module name for redirecting var cookie = new HttpCookie(ModuleParamName, _module) { Expires = DateTime.Now.AddMinutes(2) }; Response.SetCookie(cookie); }
void provider_EndRequest(object sender, PowerSchoolEventArgs e) { _module = Request.Cookies[ModuleParamName] == null ? "" : Request.Cookies[ModuleParamName].Value; if (e.Status == AuthenticationStatus.Authenticated) { if (e.Data != null) { var data = (FetchResponse)e.Data; if (data.Attributes.Contains(PowerSchoolAttributes.UserType) && data.Attributes.Contains(PowerSchoolAttributes.Dcid)) { var userType = data.Attributes[PowerSchoolAttributes.UserType].Values.FirstOrDefault(); var staffId = data.Attributes[PowerSchoolAttributes.Dcid].Values.FirstOrDefault(); int i; Logger.Trace("SSO: Usertype {0}; staffId {1}", userType, staffId); if (userType == "staff" || int.TryParse(staffId, out i)) { var token = Authentication.GetSso(staffId); if (token != null) { if (Request.QueryString[AppParamName] == null) { Response.Redirect(string.IsNullOrEmpty(_module) ? AppRelativeVirtualPath : string.Format("{0}?module={1}", AppRelativeVirtualPath, _module), false); } else { this.Token = token; this.Domain = e.Provider.Scheme + "://" + e.Provider.Host; } } if (token == null && Request.QueryString[AppParamName] == null) { this.Token = "ERROR"; this.Domain = e.Provider.Scheme + "://" + e.Provider.Host; } } } } } _module = "login"; }