Last change
on this file since 7edede9 was 7edede9, checked in by i-ina <76742075+i-ina@…>, 3 years ago |
added user register
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[bfa113e] | 1 | package it.finki.tinki.controller;
|
---|
| 2 |
|
---|
[29c0ed0] | 3 | import it.finki.tinki.model.Users.Account;
|
---|
| 4 | import it.finki.tinki.model.pojo.AccountLoginDataPojo;
|
---|
[83a5af4] | 5 | import it.finki.tinki.model.pojo.AuthResponseDataPojo;
|
---|
[29c0ed0] | 6 | import it.finki.tinki.service.AccountService;
|
---|
| 7 | import org.springframework.web.bind.annotation.*;
|
---|
[83a5af4] | 8 | import org.springframework.web.server.ResponseStatusException;
|
---|
[bfa113e] | 9 |
|
---|
| 10 | @RestController
|
---|
[3f5bf9e] | 11 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
[29c0ed0] | 12 | @RequestMapping("/api")
|
---|
[7edede9] | 13 | public class LoginController {
|
---|
[bfa113e] | 14 |
|
---|
[29c0ed0] | 15 | AccountService accountService;
|
---|
[7987457] | 16 |
|
---|
[7edede9] | 17 | public LoginController(AccountService accountService) {
|
---|
[29c0ed0] | 18 | this.accountService = accountService;
|
---|
[7987457] | 19 | }
|
---|
| 20 |
|
---|
[29c0ed0] | 21 | @PostMapping(path = "/login")
|
---|
[83a5af4] | 22 | public AuthResponseDataPojo testPage(@RequestBody AccountLoginDataPojo body) throws ResponseStatusException {
|
---|
[3f5bf9e] | 23 |
|
---|
| 24 | System.out.println(body);
|
---|
| 25 |
|
---|
[83a5af4] | 26 | Account a1 = accountService.findUser(body.getAccount(), body.getPassword(), body.getType());
|
---|
| 27 | AuthResponseDataPojo resp = new AuthResponseDataPojo();
|
---|
| 28 |
|
---|
| 29 | if(a1!=null){
|
---|
| 30 | resp.setId(a1.getId());
|
---|
| 31 | resp.setEmail(a1.getEmail());
|
---|
| 32 | resp.setName(a1.getName());
|
---|
| 33 | resp.setType(a1.getAccountType());
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | return resp;
|
---|
[bfa113e] | 37 | }
|
---|
| 38 |
|
---|
| 39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.