Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jh-boot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jan Hrabal
jh-boot
Commits
8ef38747
Commit
8ef38747
authored
Oct 15, 2019
by
Jan Hrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login field
parent
bf9b9b45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
8 deletions
+29
-8
AuthService.java
src/main/java/com/jh/boot/security/AuthService.java
+5
-4
AuthApiController.java
...main/java/com/jh/boot/security/api/AuthApiController.java
+6
-2
Signup.java
src/main/java/com/jh/boot/security/api/Signup.java
+16
-0
AppUserAuthService.java
...java/com/jh/boot/security/service/AppUserAuthService.java
+1
-1
TemplateEmailAuthServiceListener.java
...boot/security/utils/TemplateEmailAuthServiceListener.java
+1
-1
No files found.
src/main/java/com/jh/boot/security/AuthService.java
View file @
8ef38747
...
@@ -29,10 +29,11 @@ public interface AuthService {
...
@@ -29,10 +29,11 @@ public interface AuthService {
/**
/**
* Register.
* Register.
* @param locale TODO
* @param signup the signup
* @param signup the signup
* @param email
*/
* @param locale TODO
void
register
(
String
login
,
String
password
,
Locale
locale
)
throws
AuthenticationException
;
*/
void
register
(
String
login
,
String
email
,
String
password
,
Locale
locale
)
throws
AuthenticationException
;
/**
/**
...
...
src/main/java/com/jh/boot/security/api/AuthApiController.java
View file @
8ef38747
...
@@ -129,7 +129,11 @@ public class AuthApiController {
...
@@ -129,7 +129,11 @@ public class AuthApiController {
if
(!
StringUtils
.
hasText
(
signup
.
getLogin
()))
{
if
(!
StringUtils
.
hasText
(
signup
.
getLogin
()))
{
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"login"
,
"AUTH.BAD_USERNAME"
));
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"login"
,
"AUTH.BAD_USERNAME"
));
}
}
if
(!
StringUtils
.
hasText
(
signup
.
getEmail
()))
{
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"email"
,
"AUTH.BAD_EMAIL"
));
}
if
(!
PasswordUtils
.
validatePassword
(
signup
.
getPassword
()))
{
if
(!
PasswordUtils
.
validatePassword
(
signup
.
getPassword
()))
{
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"password"
,
"AUTH.BAD_PASSWORD"
));
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"password"
,
"AUTH.BAD_PASSWORD"
));
}
}
...
@@ -146,7 +150,7 @@ public class AuthApiController {
...
@@ -146,7 +150,7 @@ public class AuthApiController {
}
}
try
{
try
{
authService
.
register
(
signup
.
getLogin
(),
signup
.
getPassword
(),
locale
);
authService
.
register
(
signup
.
getLogin
(),
signup
.
get
Email
(),
signup
.
get
Password
(),
locale
);
}
catch
(
BadCredentialsException
e
)
{
}
catch
(
BadCredentialsException
e
)
{
errors
.
add
(
ErrorMessage
.
withCode
(
e
.
getMessage
()));
errors
.
add
(
ErrorMessage
.
withCode
(
e
.
getMessage
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/jh/boot/security/api/Signup.java
View file @
8ef38747
...
@@ -4,6 +4,8 @@ public class Signup {
...
@@ -4,6 +4,8 @@ public class Signup {
private
String
login
;
private
String
login
;
private
String
email
;
private
String
password
;
private
String
password
;
private
Boolean
terms
;
private
Boolean
terms
;
...
@@ -20,6 +22,13 @@ public class Signup {
...
@@ -20,6 +22,13 @@ public class Signup {
this
.
password
=
password
;
this
.
password
=
password
;
}
}
public
Signup
(
String
login
,
String
email
,
String
password
)
{
super
();
this
.
login
=
login
;
this
.
email
=
email
;
this
.
password
=
password
;
}
public
String
getLogin
()
{
public
String
getLogin
()
{
return
login
;
return
login
;
}
}
...
@@ -52,4 +61,11 @@ public class Signup {
...
@@ -52,4 +61,11 @@ public class Signup {
this
.
privacy
=
privacy
;
this
.
privacy
=
privacy
;
}
}
public
String
getEmail
()
{
return
email
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
}
src/main/java/com/jh/boot/security/service/AppUserAuthService.java
View file @
8ef38747
...
@@ -69,7 +69,7 @@ public class AppUserAuthService implements AuthService {
...
@@ -69,7 +69,7 @@ public class AppUserAuthService implements AuthService {
@Override
@Override
@Transactional
@Transactional
public
void
register
(
String
login
,
String
password
,
Locale
locale
)
throws
AuthenticationException
{
public
void
register
(
String
login
,
String
email
,
String
password
,
Locale
locale
)
throws
AuthenticationException
{
AppUser
user
=
appUserRepository
.
findByLogin
(
login
);
AppUser
user
=
appUserRepository
.
findByLogin
(
login
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
throw
new
BadCredentialsException
(
"AUTH.USER_ALREADY_EXISTS"
);
throw
new
BadCredentialsException
(
"AUTH.USER_ALREADY_EXISTS"
);
...
...
src/main/java/com/jh/boot/security/utils/TemplateEmailAuthServiceListener.java
View file @
8ef38747
...
@@ -81,7 +81,7 @@ public class TemplateEmailAuthServiceListener implements AuthServiceListener {
...
@@ -81,7 +81,7 @@ public class TemplateEmailAuthServiceListener implements AuthServiceListener {
html
=
templateService
.
evaluate
(
html
,
data
,
locale
);
html
=
templateService
.
evaluate
(
html
,
data
,
locale
);
Email
email
=
new
Email
();
Email
email
=
new
Email
();
email
.
setRecipients
(
Collections
.
singleton
(
new
EmailRecipient
(
user
.
get
Login
(),
RecipientType
.
TO
)));
email
.
setRecipients
(
Collections
.
singleton
(
new
EmailRecipient
(
user
.
get
Email
(),
RecipientType
.
TO
)));
email
.
setSubject
(
subject
);
email
.
setSubject
(
subject
);
email
.
setText
(
content
);
email
.
setText
(
content
);
email
.
setHtml
(
html
);
email
.
setHtml
(
html
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment