Assuming you already created a custom AuthUserSession, for example:
And you registered your own AuthUserSession when configuring the AuthFeature plugin, for example:
public override void Configure(Container container) { //Register all Authentication methods you want to enable for this web app. Plugins.Add(new AuthFeature( () => new CustomUserSession(), //Use your own typed Custom UserSession type new IAuthProvider[] { new CredentialsAuthProvider(), //HTML Form post of UserName/Password credentials // and any other auth providers you need })); }
Then you can provide this data to the client in the service you are creating. SocialBotstrapApi provides access to the current session information on the server as follows: Use it as a model to create a UserAuth service that returns information only for the current user.
public abstract class AppServiceBase : Service { private CustomUserSession userSession; protected CustomUserSession UserSession { get { return base.SessionAs<CustomUserSession>(); } } } [Route("/userauths")] public class UserAuths { public int[] Ids { get; set; } } public class UserAuthsResponse { public UserAuthsResponse() { this.Users = new List<User>(); this.UserAuths = new List<UserAuth>(); this.OAuthProviders = new List<UserOAuthProvider>(); } public CustomUserSession UserSession { get; set; } public List<User> Users { get; set; } public List<UserAuth> UserAuths { get; set; } public List<UserOAuthProvider> OAuthProviders { get; set; } }
source share