Exemplo n.º 1
0
 @RequestMapping(value = PUBLIC_PREFIX + ACCOUNTS_PREFIX + "/login", method = RequestMethod.POST)
 @PreAuthorize("isAnonymous()")
 public ResponseEntity<AccountLoginResponseDTO> login(@RequestBody LoginRequestDTO creds)
     throws ServiceException {
   validator.validate(creds);
   Account account = accountService.login(creds.getName(), creds.getPassword());
   account.setPassword(creds.getPassword());
   return new ResponseEntity<AccountLoginResponseDTO>(
       AccountConverter.toLoginResponse(account, secureHeaderFactory), HttpStatus.OK);
 }
Exemplo n.º 2
0
 @RequestMapping(value = PUBLIC_PREFIX + ACCOUNTS_PREFIX, method = RequestMethod.POST)
 @PreAuthorize("isAnonymous()")
 public ResponseEntity<AccountLoginResponseDTO> register(@RequestBody AccountRequestDTO newAccount)
     throws ServiceException {
   Account account = AccountConverter.fromRequest(validator, newAccount);
   DefaultProfileInjector.injectProfiles(account);
   account = accountService.register(account);
   account.setPassword(newAccount.getPassword());
   return new ResponseEntity<AccountLoginResponseDTO>(
       AccountConverter.toLoginResponse(account, secureHeaderFactory), HttpStatus.CREATED);
 }