authentication - WebApi - CurrentUserId isn't accessible until after Registration? -
i have following:
public httpresponsemessage register(registermodel model) { if (modelstate.isvalid) { // attempt register user try { websecurity.createuserandaccount(model.username, model.password); websecurity.login(model.username, model.password); initiatedatabasefornewuser(model.username); formsauthentication.setauthcookie(model.username, createpersistentcookie: false); return request.createresponse(httpstatuscode.created, websecurity.currentuserid);
in code, currentuserid (at end) resolves -1 because websecurity doesn't see new user until after method closes. i'd return profile or @ least id of newly registered user register() method - how can accomplished?
you should able id of user this:
websecurity.getuserid(model.username)
Comments
Post a Comment