File tree 11 files changed +38
-27
lines changed
polling-app-client/src/constants
11 files changed +38
-27
lines changed Original file line number Diff line number Diff line change 1
1
export const API_BASE_URL = 'http://localhost:5000' ;
2
+ //export const API_BASE_URL = 'http://polls.callicoder.com';
2
3
export const ACCESS_TOKEN = 'accessToken' ;
3
4
4
5
export const POLL_LIST_SIZE = 30 ;
Original file line number Diff line number Diff line change 14
14
<parent >
15
15
<groupId >org.springframework.boot</groupId >
16
16
<artifactId >spring-boot-starter-parent</artifactId >
17
- <version >1.5.10 .RELEASE</version >
17
+ <version >2.0.0 .RELEASE</version >
18
18
<relativePath /> <!-- lookup parent from repository -->
19
19
</parent >
20
20
Original file line number Diff line number Diff line change 9
9
import org .springframework .security .core .Authentication ;
10
10
import org .springframework .security .core .context .SecurityContextHolder ;
11
11
12
+ import java .util .Optional ;
13
+
12
14
@ Configuration
13
15
@ EnableJpaAuditing
14
16
public class AuditingConfig {
@@ -22,15 +24,17 @@ public AuditorAware<Long> auditorProvider() {
22
24
class SpringSecurityAuditAwareImpl implements AuditorAware <Long > {
23
25
24
26
@ Override
25
- public Long getCurrentAuditor () {
27
+ public Optional < Long > getCurrentAuditor () {
26
28
Authentication authentication = SecurityContextHolder .getContext ().getAuthentication ();
27
29
28
30
if (authentication == null ||
29
31
!authentication .isAuthenticated () ||
30
32
authentication instanceof AnonymousAuthenticationToken ) {
31
- return null ;
33
+ return Optional . empty () ;
32
34
}
33
35
34
- return ((UserPrincipal ) authentication .getPrincipal ()).getId ();
36
+ UserPrincipal userPrincipal = (UserPrincipal ) authentication .getPrincipal ();
37
+
38
+ return Optional .ofNullable (userPrincipal .getId ());
35
39
}
36
40
}
Original file line number Diff line number Diff line change 1
1
package com .example .polls .model ;
2
2
3
3
import javax .persistence .*;
4
+ import javax .validation .constraints .NotBlank ;
4
5
import javax .validation .constraints .NotNull ;
5
6
import javax .validation .constraints .Size ;
6
7
import java .util .Objects ;
@@ -16,7 +17,7 @@ public class Choice {
16
17
@ GeneratedValue (strategy = GenerationType .AUTO )
17
18
private Long id ;
18
19
19
- @ NotNull
20
+ @ NotBlank
20
21
@ Size (max = 40 )
21
22
private String text ;
22
23
Original file line number Diff line number Diff line change 6
6
import org .hibernate .annotations .FetchMode ;
7
7
8
8
import javax .persistence .*;
9
+ import javax .validation .constraints .NotBlank ;
9
10
import javax .validation .constraints .NotNull ;
10
11
import javax .validation .constraints .Size ;
11
12
import java .time .Instant ;
@@ -22,7 +23,7 @@ public class Poll extends UserDateAudit {
22
23
@ GeneratedValue (strategy = GenerationType .AUTO )
23
24
private Long id ;
24
25
25
- @ NotNull
26
+ @ NotBlank
26
27
@ Size (max = 140 )
27
28
private String question ;
28
29
Original file line number Diff line number Diff line change 3
3
import com .example .polls .model .audit .DateAudit ;
4
4
import org .hibernate .annotations .NaturalId ;
5
5
import javax .persistence .*;
6
+ import javax .validation .constraints .Email ;
7
+ import javax .validation .constraints .NotBlank ;
6
8
import javax .validation .constraints .NotNull ;
7
- import javax .validation .constraints .Pattern ;
8
9
import javax .validation .constraints .Size ;
9
10
import java .util .HashSet ;
10
11
import java .util .Set ;
@@ -27,20 +28,21 @@ public class User extends DateAudit {
27
28
@ GeneratedValue (strategy = GenerationType .AUTO )
28
29
private Long id ;
29
30
30
- @ NotNull
31
+ @ NotBlank
31
32
@ Size (max = 40 )
32
33
private String name ;
33
34
34
- @ NotNull
35
+ @ NotBlank
35
36
@ Size (max = 15 )
36
37
private String username ;
37
38
38
39
@ NaturalId
40
+ @ NotBlank
39
41
@ Size (max = 40 )
40
- @ Pattern ( regexp = "[^@ ]+@[^@ ]+ \\ .[^@ ]+" )
42
+ @ Email
41
43
private String email ;
42
44
43
- @ NotNull
45
+ @ NotBlank
44
46
@ Size (max = 100 )
45
47
private String password ;
46
48
Original file line number Diff line number Diff line change 1
1
package com .example .polls .payload ;
2
2
3
- import javax .validation .constraints .NotNull ;
3
+ import javax .validation .constraints .NotBlank ;
4
4
import javax .validation .constraints .Size ;
5
5
6
6
public class ChoiceRequest {
7
- @ NotNull
8
- @ Size (min = 1 , max = 40 )
7
+ @ NotBlank
8
+ @ Size (max = 40 )
9
9
private String text ;
10
10
11
11
public String getText () {
Original file line number Diff line number Diff line change 1
1
package com .example .polls .payload ;
2
2
3
- import javax .validation .constraints .NotNull ;
3
+ import javax .validation .constraints .NotBlank ;
4
4
5
5
/**
6
6
* Created by rajeevkumarsingh on 02/08/17.
7
7
*/
8
8
public class LoginRequest {
9
- @ NotNull
9
+ @ NotBlank
10
10
private String usernameOrEmail ;
11
11
12
- @ NotNull
12
+ @ NotBlank
13
13
private String password ;
14
14
15
15
public String getUsernameOrEmail () {
Original file line number Diff line number Diff line change 1
1
package com .example .polls .payload ;
2
2
3
3
import javax .validation .Valid ;
4
+ import javax .validation .constraints .NotBlank ;
4
5
import javax .validation .constraints .NotNull ;
5
6
import javax .validation .constraints .Size ;
6
7
import java .util .List ;
7
8
8
9
public class PollRequest {
9
- @ NotNull
10
- @ Size (min = 1 , max = 140 )
10
+ @ NotBlank
11
+ @ Size (max = 140 )
11
12
private String question ;
12
13
13
14
@ NotNull
Original file line number Diff line number Diff line change 1
1
package com .example .polls .payload ;
2
2
3
- import javax .validation .constraints .NotNull ;
4
- import javax .validation .constraints .Pattern ;
5
- import javax .validation .constraints .Size ;
3
+ import javax .validation .constraints .*;
6
4
7
5
/**
8
6
* Created by rajeevkumarsingh on 02/08/17.
9
7
*/
10
8
11
9
public class SignUpRequest {
12
- @ NotNull
10
+ @ NotBlank
13
11
@ Size (min = 4 , max = 40 )
14
12
private String name ;
15
13
16
- @ NotNull
14
+ @ NotBlank
17
15
@ Size (min = 3 , max = 15 )
18
16
private String username ;
19
17
20
- @ NotNull
18
+ @ NotBlank
21
19
@ Size (max = 40 )
22
- @ Pattern ( regexp = "[^@ ]+@[^@ ]+ \\ .[^@ ]+" )
20
+ @ Email
23
21
private String email ;
24
22
25
- @ NotNull
23
+ @ NotBlank
26
24
@ Size (min = 6 , max = 20 )
27
25
private String password ;
28
26
Original file line number Diff line number Diff line change @@ -22,3 +22,6 @@ spring.jackson.time-zone= UTC
22
22
# # App Properties
23
23
app.jwtSecret = JWTSuperSecretKey
24
24
app.jwtExpirationInMs = 604800000
25
+
26
+ # # Spring Profiles
27
+ # spring.profiles.active=prod
You can’t perform that action at this time.
0 commit comments