0

I want to add new field(s) on UserAuth table (for example : blocked, verified) and I want to check when login. How I can do this? I did not found any tutorial about customization authentication.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Ersin Tarhan
  • 321
  • 3
  • 11
  • Refer to this previous answer for different ways of [extending ServiceStack Authentication and UserAuth models](http://stackoverflow.com/a/11118747/85785). – mythz Mar 16 '15 at 19:12
  • @mythz : Thank you, but its very confused. Finally I used cacheclient + session feauture with custom request filter. – Ersin Tarhan Mar 17 '15 at 00:10

1 Answers1

1

Finally I found otherway solution for my project...

1) Add plug-in SessionFeaute :

this.Plugins.Add(new SessionFeature() { SessionExpiry = TimeSpan.FromMinutes(15) });

2) Register ICacheClient :

  container.Register<ICacheClient>(new MemoryCacheClient());

3) Authenticate Method :

  public void Authenticate(ISession session , User user)
    {
        session.Set("UserInfo",user);
    }

4) Logout Method : session.GetSessionBag().Set<User>("UserInfo",null);

5) RequestFilter :

public class UserInfoFilterAttribute : RequestFilterAttribute
{
    public UserInfoFilterAttribute() { }
    public UserInfoFilterAttribute(ApplyTo applyTo) : base(applyTo) { }
    public override void Execute(IRequest req, IResponse res, object requestDto)
    {
            var user = req.GetSessionBag().Get<User>("UserInfo");
            if (user == null)
            {
              res.StatusCode = (int)HttpStatusCode.Unauthorized;
              res.EndRequest();
            }
    }
}

6) Finally Using Filter for restricted service.

  [UserInfoFilterAttribute]
public class AccountInfoService : ServiceStack.Service
{

}

Thanks anyway...

Ersin Tarhan
  • 321
  • 3
  • 11