public ActionResult Login([FromBody] ConnectionInfo user) { if (user.Email == null || user.Password == null) { return(BadRequest(new { message = "Demande du client invalide" })); } if (user.Email == "test" && user.Password == "123") { var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("superSecretKey@345")); var signinCredentials = new SigningCredentials(secretKey, SecurityAlgorithms.HmacSha256); var tokeOptions = new JwtSecurityToken( issuer: "http://localhost:5000", audience: "http://localhost:5000", claims: new List <Claim>(), expires: DateTime.Now.AddMinutes(15), signingCredentials: signinCredentials ); ConnectionValidation connexionValidation = new ConnectionValidation(); connexionValidation.token = new JwtSecurityTokenHandler().WriteToken(tokeOptions); return(Ok(new { Validation = connexionValidation })); } else { return(Unauthorized(new { message = "Courriel ou mot de passe invalide" })); //return Unauthorized(); } }
public LoginPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) { _navigationService = navigationService; loginModel = new LoginModel(); try { SaveLoginCommand = new DelegateCommand(async() => { if (ConnectionValidation.HaveInternetConnection()) { await LoginValidations(loginModel); } else { await pageDialogService.DisplayAlertAsync(ErrorCodes.Error, ErrorCodes.NoInternet, ErrorCodes.Cancel); } }); ToRegisterPageCommand = new DelegateCommand(async() => { await ToRegisterPage(); }); } catch (Exception ex) { pageDialogService.DisplayAlertAsync(ErrorCodes.Error, ex.Message, ErrorCodes.Cancel); } }
public RegisterPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) { registerModel = new RegisterModel(); try { SaveRegisterCommand = new DelegateCommand(async() => { if (ConnectionValidation.HaveInternetConnection()) { await RegisterValidations(registerModel); } else { await pageDialogService.DisplayAlertAsync(ErrorCodes.Error, ErrorCodes.NoInternet, ErrorCodes.Cancel); } }); } catch (Exception ex) { pageDialogService.DisplayAlertAsync(ErrorCodes.Error, ex.Message, ErrorCodes.Cancel); } }