Last active
June 9, 2019 05:09
-
-
Save hiranya911/e438477d6e6d7097a89e09e241b55edb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| using FirebaseAdmin.Auth; | |
| [Route("login")] | |
| public class LoginController : ControllerBase | |
| { | |
| private readonly UserStore userStore = new UserStore(); | |
| [HttpPost] | |
| public async Task<ActionResult> Login([FromBody] LoginRequest request) | |
| { | |
| try | |
| { | |
| var user = await this.userStore.LoginAsync(request); | |
| var token = await FirebaseAuth.DefaultInstance.CreateCustomTokenAsync( | |
| user.Uid, user.Claims); | |
| return this.Ok(new LoginResult() | |
| { | |
| CustomToken = token, | |
| }); | |
| } | |
| catch (Exception e) | |
| { | |
| return this.StatusCode(401, new { Error = e.Message }); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment