-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73a0c31
commit da4138f
Showing
6 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/src/main/java/com/oskarwiedeweg/cloudwork/user/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.oskarwiedeweg.cloudwork.user; | ||
|
||
import com.oskarwiedeweg.cloudwork.user.dto.Setup2FADto; | ||
import lombok.Data; | ||
import org.springframework.security.access.prepost.PreAuthorize; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.Map; | ||
|
||
@Data | ||
@RestController | ||
@RequestMapping("/v1/user") | ||
public class UserController { | ||
|
||
private final UserService userService; | ||
|
||
@GetMapping("/2fa/setup") | ||
@PreAuthorize("isAuthenticated()") | ||
public Setup2FADto setup2FA(@AuthenticationPrincipal Long userId) { | ||
return userService.setup2FA(userId); | ||
} | ||
|
||
@PostMapping("/2fa/verify/{code}") | ||
@PreAuthorize("isAuthenticated()") | ||
public Map<String, Boolean> verify2FA(@AuthenticationPrincipal Long userId, @PathVariable("code") Long code, @RequestParam("tempToken") String tempToken) { | ||
return Map.of("valid", userService.setup2FA(userId, code, tempToken)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/src/main/java/com/oskarwiedeweg/cloudwork/user/dto/Setup2FADto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.oskarwiedeweg.cloudwork.user.dto; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Setup2FADto { | ||
|
||
private final String qrCode; | ||
private final String tempToken; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters