Hello,
I need to save after a successfull login some data related to the authenticated user, e.g. some internal id, activation date and so on… I’ve seen that when overriding the public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary<string, string> authInfo) I’ve got this authInfo… what this for? can it be used for this purpose? I’ve tried to retrieve this authInfo under the service.Request but I wasn’t able to spot it… is it propagated somewhere? I’ve also seen that OAuth provider exposes it but as I’ve seen it just on Authentication process, not for retrieval.
Thanks in advance
Paolo
Yeah the OnAuthenticated hook on your Custom AuthUserSession gets called once after a successful login so you can use it to do run any custom logic after they’re logged in.
The authService is a reference to the AuthenticateService class which lets you also retrieve dependencies from the IOC with:
using (var db = authService.TryResolve<IDbConnectionFactory>()) {
//…
}
paolo ponzano:
Hello Demis, thanks ok but after the Authentication is completed, how do I get those information (saved in AuthInfo) on the Service side?
You should just set them on properties on your Custom AuthUserSession, then you can just retrieve it in your services with:
var session = base.SessionAs<CustomAuthSession>();
paolo ponzano:
Excuse me again, I’ve created my own session class that implements IAuthSession with one additional field, but where should I tell SS that I wish to use myAuthSession as IAuthSession? Thanks
paolo ponzano:
OK I’ve found it on AppHost.Configure…Thanks!