Guest User

Untitled

a guest
Feb 16th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. postAdminUsertoDashboard( user: User) : Observable<Number>{
  2. let dashboard_login: string ="/xyz/dashboard-login/login";
  3. let body = "userName=" + user.getUserName + "&password=" + user.getPassword;
  4. return this.http.post(this.base_url,body)
  5. .map(success => success.status).catch(this.handleError);
  6. }
  7.  
  8. @RequestMapping(value = "/login", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
  9. public ResponseEntity<Object> authenticateUser(@RequestParam("userName") String userName, @RequestParam("password") String password)
  10. {
  11. final Logger logger = LoggerFactory.getLogger(AdminUserController.class);
  12. AdminUserDomain adminUser = adminUserService.authenticate(userName);
  13. if(adminUser == null) {
  14. ExceptionDomain domainException = new ExceptionDomain(1001,"User not found",null);
  15. return new ResponseEntity<Object>(domainException, HttpStatus.INTERNAL_SERVER_ERROR);
  16. }
  17.  
  18. if(!password.equals(adminUser.getPassword())) {
  19. ExceptionDomain domainException = new ExceptionDomain(1002,"Password is incorrect",null);
  20. return new ResponseEntity<Object>(domainException, HttpStatus.INTERNAL_SERVER_ERROR);
  21. }
  22. return new ResponseEntity<Object>(adminUser, HttpStatus.ACCEPTED);
Add Comment
Please, Sign In to add comment