public object Any(HelloRequest request) { SessionBag.Set(HelloServiceCounterKey, SessionBag.Get <int>(HelloServiceCounterKey) + 1); var userSession = SessionAs <CustomUserSession>(); var roles = string.Join(", ", userSession.Roles.ToArray()); return(new HelloResponse { Result = "Hello, " + request.Name + ", your role(s): " + roles }); }
public object Any(SiteAuthenticate request) { var siteInfo = AssertSite(request.Slug); var siteSession = SessionBag.Get <SiteSession>(); if (siteSession?.User != null && request.provider != AuthenticateService.LogoutAction && request.provider == null) { return(siteSession.User); } try { var client = CreateSiteClient(siteInfo); var authRequest = request.ConvertTo <Authenticate>(); if (request.AccessToken?.IndexOf(':') >= 0) //required for AuthProviders needing both Access+Secret (e.g. twitter) { authRequest.AccessTokenSecret = request.AccessToken.LeftPart(':'); //secret is first part when both provided authRequest.AccessToken = request.AccessToken.RightPart(':'); } if (nonProviders.Contains(request.provider)) { authRequest.provider = null; if (request.provider == "bearer") { client.BearerToken = request.AccessToken; } else if (request.provider == "session") { client.SetSessionId(request.AccessToken); } else if (request.provider == "authsecret") { client.Headers[HttpHeaders.XParamOverridePrefix + Keywords.AuthSecret] = request.AccessToken; } } var response = client.Post(authRequest); siteSession = SiteSession.Create(request, response); SessionBag.Set(siteSession); } finally { if (request.provider == AuthenticateService.LogoutAction) { SessionBag.Remove <SiteSession>(); siteSession = null; } } return(siteSession?.User); }
public object Any(Session request) { var untyped = SessionBag["untyped"] as CustomSession ?? new CustomSession(); var typed = SessionBag.Get <CustomSession>("typed") ?? new CustomSession(); untyped.Counter++; typed.Counter++; SessionBag["untyped"] = untyped; SessionBag.Set("typed", typed); var response = new SessionResponse { Typed = typed, UnTyped = untyped, }; return(response); }
public object Any(UpdateSession request) { var session = SessionAs <CustomUserSession>(); session.CustomName = request.CustomName; var unAuthInfo = SessionBag.Get <UnAuthInfo>() ?? new UnAuthInfo(); unAuthInfo.CustomInfo = request.CustomName + " - CustomInfo"; SessionBag.Set(unAuthInfo); this.SaveSession(session); return(new GetSessionResponse { Result = SessionAs <CustomUserSession>(), UnAuthInfo = unAuthInfo, }); }