com.osomapps.pt.tokenemail.EmailResetResource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 0
f 0
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A EmailResetResource(TokenEmailSignupService) 0 3 1
A create(String) 0 7 2
A list() 0 3 1
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