Skip to content

Commit

Permalink
Issue151 (#191)
Browse files Browse the repository at this point in the history
* Issue161 - SonstQubeServerTest korrigiert.

* Issue #168

* Fixes Issue #151
  • Loading branch information
ChristopherRBrown authored and Christoph-Meyer committed Mar 5, 2019
1 parent 1a21941 commit 4bd4d4c
Show file tree
Hide file tree
Showing 10 changed files with 1,025 additions and 996 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ A tool for extending [SonarQube](https://www.sonarqube.org/) by a gamification s
* more about SonarQuest's game concepts and application scenarios: https://www.viadee.de/sonarquest_en
* Sonar Quest info package: https://github.com/viadee/sonarQuest/blob/master/docs/SonarQuest_info_package.pdf

## News

*2019-02-27*

German SonarQuest Coders are invited to the 1st Coding Night: https://lp.viadee.de/sonar-quest-coding-night-anmeldung
Coding Night starts at 1800 hrs today! (Chris)

## Goal

Reduce technical debts in your code project by converting the refactoring process into a game. Create quests from SonarQube issues and write your own story.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.viadee.sonarquest.controllers.PathConstants;
import com.viadee.sonarquest.security.JwtHelper;
import com.viadee.sonarquest.services.UserService;

@RestController
@RequestMapping(PathConstants.LOGIN_URL)
Expand All @@ -33,6 +34,9 @@ public class LoginController {
@Autowired
private JwtHelper jwtHelper;

@Autowired
private UserService userService;

@GetMapping
public String info() {
return "Dies ist eine Login Seite";
Expand All @@ -41,10 +45,11 @@ public String info() {
@PostMapping
public Token login(@Valid @RequestBody final UserCredentials credentials) {

String username = credentials.getUsername();
final String username = credentials.getUsername();
LOGGER.info("Log-In request received from user {}", Objects.hashCode(username));
final User authenticatedUser = authentificateUser(credentials);
final Token token = createTokenForUser(authenticatedUser);
userService.updateLastLogin(authenticatedUser.getUsername());
LOGGER.info("Log-In request successful for user {}", Objects.hashCode(username));
return token;
}
Expand All @@ -55,12 +60,12 @@ private User authentificateUser(final UserCredentials credentials) {
}

private Authentication authenticate(final UserCredentials credentials) {
String username = credentials.getUsername();
UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(username,
final String username = credentials.getUsername();
final UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(username,
credentials.getPassword());
try {
return authenticationManager.authenticate(authToken);
} catch (BadCredentialsException ex) {
} catch (final BadCredentialsException ex) {
LOGGER.warn(String.format("Log-In request denied with bad credentials for user %s",
Objects.hashCode(username)));
throw ex;
Expand Down
Loading

0 comments on commit 4bd4d4c

Please sign in to comment.