Advertisement
Guest User

Untitled

a guest
Feb 15th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. public class RoomsAuthProvider : BasicAuthProvider
  2. {
  3. public RoomsAuthProvider(AppSettings appSettings) : base(appSettings)
  4. {
  5. }
  6.  
  7. public RoomsAuthProvider()
  8. {
  9. }
  10.  
  11. public override bool TryAuthenticate(IServiceBase authService,
  12. string userName, string password)
  13. {
  14. return true;
  15. }
  16.  
  17. public override IHttpResult OnAuthenticated(IServiceBase authService,
  18. IAuthSession session, IAuthTokens tokens,
  19. Dictionary<string, string> authInfo)
  20. {
  21. session.FirstName = "some_firstname_from_db";
  22. return base.OnAuthenticated(authService, session, tokens, authInfo);
  23. }
  24. }
  25.  
  26. public override void Configure(Funq.Container container)
  27. {
  28. container.Register<ICacheClient>(new MemoryCacheClient());
  29.  
  30. Plugins.Add(new AuthFeature(() => new AuthUserSession(),
  31. new IAuthProvider[]
  32. {
  33. new RoomsAuthProvider()
  34. }));
  35.  
  36. Plugins.Add(new ServerEventsFeature());
  37. }
  38.  
  39. var client = new ServerEventsClient("http://localhost:1337/", "home")
  40.  
  41. var authResponse = client.Authenticate(new Authenticate
  42. {
  43. provider = "RoomsAuthProvider",
  44. UserName = "test@gmail.com",
  45. Password = "p@55w0rd",
  46. RememberMe = true,
  47. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement