Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyCustomCredentialsAuthProvider : CredentialsAuthProvider
- {
- public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
- {
- if (userName == "testuser" && password == "1234")
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public override IHttpResult OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens,
- Dictionary<string, string> authInfo)
- {
- session.FirstName = "Testuser Joe Doe";
- authService.SaveSession(session, SessionExpiry);
- return null;
- }
- }
- public partial class App : Application
- {
- public JsonServiceClient ServiceClient { get; private set; }
- public App()
- {
- this.InitializeComponent();
- }
- // ....
- }
- private void Login()
- {
- var baseUri = $"http://{AppServer}:8088";
- ((App)Application.Current).InitServiceClient(baseUri);
- var client = ((App) Application.Current).ServiceClient;
- //var response = client.Send<AuthResponse>(new Auth { UserName = "Test", Password = "TestPassword" });
- var authResponse = client.Post(new Authenticate
- {
- provider = CredentialsAuthProvider.Name, // <-- WHAT SHOULD THIS BE???
- UserName = "testuser",
- Password = "1234",
- RememberMe = true,
- });
- // ....
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement