public string GetToken() { string username = HttpContext.Current.Request.Headers["username"]; string password = HttpContext.Current.Request.Headers["password"]; if (username == null || password == null) { throw new Exception("Unauthorized"); } BusinessContext context = new BusinessContext(); User user = context.UserBusiness.ReadUser(username, password); if (user == null) { throw new Exception("Unauthorized"); } return(JwtTokenLibrary.GenerateToken(username, user.Role.ToString(), RsaEncryption.Encryption(password))); }