Last active
June 18, 2019 10:01
-
-
Save nest-don/757b0ace09cb85fad6e3826a4b39c55f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Result | |
{ | |
Succeeded = 0, | |
Failed = -1, | |
Unauthorized = -5, | |
InternalError = -10, | |
UserNotFound = -15, | |
IncorrectEmail = -20, | |
EmailNotConfirmed = -25, | |
IncorrectSecurityCode = -30, | |
InvalidPermit = -35, | |
InvalidShare = -40, | |
LoginFailed = -45 | |
} | |
// GET api/permits/{email} | |
[HttpGet("{email}")] | |
public async Task<object> QueryTokenAsync(string email, [FromQuery] string password) | |
{ | |
if (string.IsNullOrEmpty(email)) | |
{ | |
return this.NestResult(Result.IncorrectEmail); | |
} | |
var result = await _signInManager.PasswordSignInAsync(email, password, false, false); | |
if (result.Succeeded) | |
{ | |
Permit permit = new Permit(); | |
permit.Password = password; | |
permit.Owner = await _userManager.FindByNameAsync(email); | |
permit.Token = await GenerateJwtTokenAsync(permit.Owner); | |
return this.NestResultSingle( | |
Result.Succeeded, permit, "A new token has been created for the permit"); | |
} | |
return this.NestResult(Result.LoginFailed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment