Skip to content

Commit 43d7abe

Browse files
author
noobandy
committed
Registration and notification
1 parent a1f15f0 commit 43d7abe

File tree

21 files changed

+1238
-514
lines changed

21 files changed

+1238
-514
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@
239239
<artifactId>jstl</artifactId>
240240
<version>1.2</version>
241241
</dependency>
242+
<dependency>
243+
<groupId>net.tanesha.recaptcha4j</groupId>
244+
<artifactId>recaptcha4j</artifactId>
245+
<version>0.0.7</version>
246+
</dependency>
242247

243248
<!-- Test -->
244249
<dependency>

src/main/java/in/anandm/apps/template/application/impl/CustomUserDetailsService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public UserDetails loadUserByUsername(String username)
3434
throw new UsernameNotFoundException("user name not found exception");
3535
}else{
3636
UserAccount account = user.getUserAccount();
37-
boolean accountNonExpired = account.getExpireOn() > System.currentTimeMillis();
37+
38+
boolean accountNonExpired = true;
39+
if(account.getExpireOn() != null ){
40+
accountNonExpired = account.getExpireOn() > System.currentTimeMillis();
41+
}
3842
List<GrantedAuthority> authorities = Collections.emptyList();
3943
UserDetails userDetails = new CustomUserDetails(account.getUserId(), account.getPassword(), account.getEnabled(), accountNonExpired, true, true, authorities);
4044
CustomUserDetails details = (CustomUserDetails) userDetails;

src/main/java/in/anandm/apps/template/domain/model/user/IUserRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface IUserRepository {
1515

1616
void saveUser(User user);
1717
User getUserByUserId(String userId);
18-
1918
DataTable<User> getDataTable(Map<String, String> params);
19+
2020
}

src/main/java/in/anandm/apps/template/interfaces/web/HomeController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import in.anandm.apps.template.domain.model.user.UserAccount;
66
import in.anandm.apps.template.domain.model.user.UserProfile;
77
import in.anandm.apps.template.domain.service.IUserService;
8-
import in.anandm.apps.template.domain.service.UserService;
98

109
import java.text.DateFormat;
1110
import java.util.Date;

src/main/java/in/anandm/apps/template/interfaces/web/LoginController.java

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.interfaces.web;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* @author anandm
10+
*
11+
*/
12+
public class Notification implements Serializable {
13+
14+
/**
15+
*
16+
*/
17+
private static final long serialVersionUID = 1L;
18+
19+
private String type;
20+
private String style;
21+
private String position;
22+
private String message;
23+
24+
25+
/**
26+
* @param type
27+
* @param style
28+
* @param position
29+
* @param message
30+
*/
31+
public Notification(String type, String style, String position, String message) {
32+
super();
33+
this.type = type;
34+
this.style = style;
35+
this.position = position;
36+
this.message = message;
37+
}
38+
/**
39+
*
40+
*/
41+
public Notification() {
42+
super();
43+
44+
}
45+
public String getType() {
46+
return type;
47+
}
48+
public void setType(String type) {
49+
this.type = type;
50+
}
51+
public String getStyle() {
52+
return style;
53+
}
54+
public void setStyle(String style) {
55+
this.style = style;
56+
}
57+
public String getPosition() {
58+
return position;
59+
}
60+
public void setPosition(String position) {
61+
this.position = position;
62+
}
63+
public String getMessage() {
64+
return message;
65+
}
66+
public void setMessage(String message) {
67+
this.message = message;
68+
}
69+
70+
71+
72+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.interfaces.web;
5+
6+
import java.util.ArrayList;
7+
8+
import org.springframework.stereotype.Component;
9+
import org.springframework.web.context.request.RequestContextHolder;
10+
import org.springframework.web.context.request.ServletRequestAttributes;
11+
12+
/**
13+
* @author anandm
14+
*
15+
*/
16+
@Component
17+
public class NotificationHelper {
18+
19+
private static final String NOTIFICATION_ATTR = "notifications";
20+
21+
public static final void notify(Notification notification){
22+
23+
@SuppressWarnings("unchecked")
24+
ArrayList<Notification> notifications = (ArrayList<Notification>) RequestContextHolder.getRequestAttributes().getAttribute(NOTIFICATION_ATTR, ServletRequestAttributes.SCOPE_SESSION);
25+
26+
if(notifications == null){
27+
notifications = new ArrayList<Notification>();
28+
}
29+
30+
notifications.add(notification);
31+
RequestContextHolder.getRequestAttributes().setAttribute(NOTIFICATION_ATTR,notifications, ServletRequestAttributes.SCOPE_SESSION);
32+
33+
34+
}
35+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
*
3+
*/
4+
package in.anandm.apps.template.interfaces.web.login.controller;
5+
6+
import java.text.SimpleDateFormat;
7+
import java.util.Date;
8+
9+
import org.springframework.beans.propertyeditors.CustomDateEditor;
10+
import org.springframework.web.bind.WebDataBinder;
11+
import org.springframework.web.bind.annotation.InitBinder;
12+
13+
/**
14+
* @author anandm
15+
*
16+
*/
17+
18+
public class BaseController {
19+
20+
@InitBinder
21+
public void initBinder(WebDataBinder webDataBinder){
22+
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
23+
webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
24+
}
25+
}

0 commit comments

Comments
 (0)