create(String)   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
1
package com.osomapps.pt.tokenemail;
2
3
import com.osomapps.pt.token.InUser;
4
import java.util.Collections;
5
import java.util.List;
6
import java.util.Optional;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.web.bind.annotation.GetMapping;
9
import org.springframework.web.bind.annotation.PathVariable;
10
import org.springframework.web.bind.annotation.RequestMapping;
11
import org.springframework.web.bind.annotation.RestController;
12
13
@RestController
14
@RequestMapping("email/reset")
15
class EmailResetResource {
16
17
    private final TokenEmailSignupService tokenEmailSignupService;
18
19
    @Autowired
20
    EmailResetResource(TokenEmailSignupService tokenEmailSignupService) {
21
        this.tokenEmailSignupService = tokenEmailSignupService;
22
    }
23
24
    @GetMapping
25
    List<InUser> list() {
26
        return Collections.emptyList();
27
    }
28
29
    @GetMapping("{resetToken}")
30
    String create(@PathVariable String resetToken) {
31
        final Optional<String> newPassword = tokenEmailSignupService.resetToken(resetToken);
32
        if (newPassword.isPresent()) {
33
            return "Your password was reseted to the " + newPassword.get();
34
        }
35
        return "";
36
    }
37
}
38