Advertisement
Guest User

Untitled

a guest
Oct 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. public class MyCustomCredentialsAuthProvider : CredentialsAuthProvider
  2. {
  3. public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
  4. {
  5. if (userName == "testuser" && password == "1234")
  6. {
  7. return true;
  8. }
  9. else
  10. {
  11. return false;
  12. }
  13. }
  14.  
  15. public override IHttpResult OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens,
  16. Dictionary<string, string> authInfo)
  17. {
  18. session.FirstName = "Testuser Joe Doe";
  19.  
  20. authService.SaveSession(session, SessionExpiry);
  21. return null;
  22. }
  23.  
  24. }
  25.  
  26. public partial class App : Application
  27. {
  28. public JsonServiceClient ServiceClient { get; private set; }
  29.  
  30. public App()
  31. {
  32. this.InitializeComponent();
  33. }
  34. // ....
  35. }
  36.  
  37. private void Login()
  38. {
  39. var baseUri = $"http://{AppServer}:8088";
  40. ((App)Application.Current).InitServiceClient(baseUri);
  41. var client = ((App) Application.Current).ServiceClient;
  42.  
  43. //var response = client.Send<AuthResponse>(new Auth { UserName = "Test", Password = "TestPassword" });
  44. var authResponse = client.Post(new Authenticate
  45. {
  46. provider = CredentialsAuthProvider.Name, // <-- WHAT SHOULD THIS BE???
  47. UserName = "testuser",
  48. Password = "1234",
  49. RememberMe = true,
  50. });
  51. // ....
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement