Last change
on this file since 721cb87 was 7edede9, checked in by i-ina <76742075+i-ina@…>, 4 years ago |
added user register
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | package it.finki.tinki.controller;
|
---|
2 |
|
---|
3 | import it.finki.tinki.model.Users.Account;
|
---|
4 | import it.finki.tinki.model.pojo.AccountLoginDataPojo;
|
---|
5 | import it.finki.tinki.model.pojo.AuthResponseDataPojo;
|
---|
6 | import it.finki.tinki.service.AccountService;
|
---|
7 | import org.springframework.web.bind.annotation.*;
|
---|
8 | import org.springframework.web.server.ResponseStatusException;
|
---|
9 |
|
---|
10 | @RestController
|
---|
11 | @CrossOrigin(origins = "http://localhost:3000")
|
---|
12 | @RequestMapping("/api")
|
---|
13 | public class LoginController {
|
---|
14 |
|
---|
15 | AccountService accountService;
|
---|
16 |
|
---|
17 | public LoginController(AccountService accountService) {
|
---|
18 | this.accountService = accountService;
|
---|
19 | }
|
---|
20 |
|
---|
21 | @PostMapping(path = "/login")
|
---|
22 | public AuthResponseDataPojo testPage(@RequestBody AccountLoginDataPojo body) throws ResponseStatusException {
|
---|
23 |
|
---|
24 | System.out.println(body);
|
---|
25 |
|
---|
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;
|
---|
37 | }
|
---|
38 |
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.