public async Task <IActionResult> SignIn([FromBody] SignInModel model) { #region Validate Model var userInputValidated = _signInModelValidator.Validate(model); if (!userInputValidated.IsValid) { _infos.Add(_badRequest.ShowError(int.Parse(userInputValidated.Errors[0].ErrorMessage)).Message); return(BadRequest(new CustomResponse <string> { Message = _infos })); } #endregion #region Supply User Agent values model.ApiVersion = "1.0"; model.UserAgent = UserAgent; model.AppVersion = Version; #endregion var signedIn = await _myAuthentication.SignInTheReturnUser(model); return(Ok(signedIn)); }
public async Task <IActionResult> LoginAsync([FromBody] LoginModel model) { var user = await _authenticate.LoginThenReturnUser(model); if (user != null) { if (!user.EmailConfirmed) { return(BadRequest(new { error = _badRequest.ShowError(_badRequest.ErrUserUnverified) })); } return(AcceptedAtAction("GetUser", "UserHome", new { username = user.UserName }, new { data = user, link = new { self = Url.Action("GetUser", "UserHome", new { username = user.UserName }, Request.Scheme) } })); } return(BadRequest(_badRequest.ShowError(_badRequest.ErrAuthenticationFailed))); }
public async Task <IActionResult> NewUserAsync([FromBody] AddUpModel model) { var uri = HttpContext.Request.Host.Value; var user = await _user.NewAccountAsync(model, ""); if (user == null) { return(BadRequest(new { error = _badRequest.ShowError( _badRequest.ErrAccountDuplication ) })); } //Send Verification Email to User //try //{ // var code = await _user.GenerateEmailConfirmation(model.Email, "", ""); //} //catch (System.Exception ex) //{ // return BadRequest(new // { // error = ex.Message, // errorstack = ex.StackTrace // }); //} //return CreatedAtAction("Index", "Home", new //{ // username = user.Username //}, new //{ // data = user, // link = new // { // self = Url.Action("Index", "Home", new // { // username = user.Username // }, Request.Scheme) // } //}); return(Ok()); }
public async Task <IActionResult> CreateUser([FromBody] CreateUserModel model) { #region Validate Model var userInputValidated = _userModelValidator.Validate(model); if (!userInputValidated.IsValid) { _infos.Add(_badRequest.ShowError(int.Parse(userInputValidated.Errors[0].ErrorMessage)).Message); return(BadRequest(new CustomResponse <string> { Message = _infos })); } #endregion var createdUser = await _user.CreateUser(model); return(Ok(createdUser)); }