public IActionResult Login([FromBody] Login user) { var dbUser = Authentification.Login(user); if (dbUser != null) { string token = JwtGenerator.GenerateJSONWebToken(dbUser.Id); Response.Headers.Add("Token", token); return(Ok()); } else { return(BadRequest("Your password or username is incorrect")); } }
public IActionResult ResetPassword(Login login) { try { User user = Authentification.UserLink(login.Username); string token = JwtGenerator.GenerateJSONWebToken(user.Id); Response.Headers.Add("Token", token); Uri domain = new Uri(Request.GetDisplayUrl()); Uri uri = new Uri(domain.Scheme + "://" + domain.Host + (domain.IsDefaultPort ? "" : ":" + domain.Port)); string url = uri.ToString(); EmailManager.SendEmail(user, token, url); return(Ok()); } catch { return(BadRequest()); } }