c# - ServiceStack Custom User Authentication -


does have actual example of how use int refid proposed in question?

i trying authentication going need marry userauth data own user table. problem have no idea how pass additional parameter "/register" method. guess i'm looking event "onadduser" allow me throw additional parameters mix.

i managed user registration working pretty quickly, super easy. maybe problem easy? can see work can't figure out how between , database.

either dictionary approach or refid approach work me, it's no obvious me how use either.

is possible override create user altogether? found code:

myservices.cs

which looks it's doing create user in place of "/register" there other articles suggest can't override servicestack dtos, have use default tables.

you include own register service using copy of registerservice source code , modify suit needs, e.g. use custom register dto additional properties want.

but can pass additional params without changing existing register dto adding ?querystring can access inside services with:

var myparam = base.request.querystring["myparam"]; 

otherwise way add custom logic during registration or authentication tap existing session or auth events.

techstacks has example of in customauthusersession:

public class customusersession : authusersession {     public string defaultprofileurl { get; set; }      public string githubprofileurl { get; set; }     public string twitterprofileurl { get; set; }      public override void onauthenticated(iservicebase authservice,          iauthsession session,          iauthtokens tokens,          dictionary<string, string> authinfo)     {         base.onauthenticated(authservice, session, tokens, authinfo);         var appsettings = authservice.tryresolve<iappsettings>();         var userauthrepo = authservice.tryresolve<iauthrepository>();         var userauth = userauthrepo.getuserauth(session, tokens);         var dbconnectionfactory = authservice.tryresolve<idbconnectionfactory>();         foreach (var authtokens in session.provideroauthaccess)         {             if (authtokens.provider.tolower() == "github")             {                 githubprofileurl = session.getprofileurl();             }             if (authtokens.provider.tolower() == "twitter")             {                 twitterprofileurl = session.getprofileurl();                 if (appsettings.getlist("twitteradmins").contains(session.username)                      && !session.hasrole(rolenames.admin))                 {                     userauthrepo.assignroles(userauth, roles:new[]{rolenames.admin});                 }             }              defaultprofileurl = githubprofileurl ?? twitterprofileurl;             using (var db = dbconnectionfactory.opendbconnection())             {                 var userauthinstance = db.single<customuserauth>(x =>                      x.id == this.userauthid.toint());                 if (userauthinstance != null)                 {                     userauthinstance.defaultprofileurl = this.defaultprofileurl;                     db.save(userauthinstance);                 }             }         }     } } 

which fetches profile url of user when login via github or twitter. assign admin role users in twitteradmins appsetting, way assign admin rights known twitter users. retrieved profile url added customuserauth poco table , saved.

techstacks tells servicestack use own customuserauth table instead registering generic ormliteauthrepository:

var authrepo = new ormliteauthrepository<customuserauth, userauthdetails>(dbfactory); container.register<iuserauthrepository>(authrepo); authrepo.initschema(); 

where save user information in customuserauth instead of default userauth table.