save registration id on server during login
This commit is contained in:
1 parent
e893a95eee
commit
eb4796ca34
2 files changed
+19
-1
No files matched your search
@@ -49,16 +49,23 @@ public class UserController {
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String login(@RequestParam String login,@RequestParam String password) throws JSONException{
|
||||
public String login(@RequestParam String login, @RequestParam String password, @RequestParam String registrationId) throws JSONException{
|
||||
JSONObject loginResponse = new JSONObject();
|
||||
boolean userFound = false;
|
||||
|
||||
for(User user: userRepository.findAll()){
|
||||
if(login.equals(user.getEmail()) && password.equals(user.getPassword())){
|
||||
userFound = true;
|
||||
|
||||
//save users registration id
|
||||
user.setRegistratioId(registrationId);
|
||||
userRepository.save(user);
|
||||
|
||||
loginResponse.put("success", true);
|
||||
loginResponse.put("userId", user.getUserId());
|
||||
|
||||
loginResponse.put("registrationId", user.getRegistratioId());
|
||||
|
||||
//access codes
|
||||
JSONArray accessCodes = new JSONArray();
|
||||
for(Role role : user.getRoles()){
|
||||
|
||||
@@ -24,6 +24,17 @@ public class User {
|
||||
@Basic
|
||||
private String password;
|
||||
|
||||
public String getRegistratioId() {
|
||||
return registratioId;
|
||||
}
|
||||
|
||||
public void setRegistratioId(String registratioId) {
|
||||
this.registratioId = registratioId;
|
||||
}
|
||||
|
||||
@Basic
|
||||
private String registratioId;
|
||||
|
||||
@ManyToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
|
||||
@JoinTable(
|
||||
name="User_Role",
|
||||
|
||||
Reference in new issue
Block a user