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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
5 deletions
+26
-5
AuthService.java
src/main/java/com/jh/boot/security/AuthService.java
+3
-2
AuthApiController.java
...main/java/com/jh/boot/security/api/AuthApiController.java
+5
-1
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 {
/**
* Register.
* @param locale TODO
* @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
...
...
@@ -130,6 +130,10 @@ public class AuthApiController {
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
()))
{
errors
.
add
(
ErrorMessage
.
withFieldCode
(
"password"
,
"AUTH.BAD_PASSWORD"
));
}
...
...
@@ -146,7 +150,7 @@ public class AuthApiController {
}
try
{
authService
.
register
(
signup
.
getLogin
(),
signup
.
getPassword
(),
locale
);
authService
.
register
(
signup
.
getLogin
(),
signup
.
get
Email
(),
signup
.
get
Password
(),
locale
);
}
catch
(
BadCredentialsException
e
)
{
errors
.
add
(
ErrorMessage
.
withCode
(
e
.
getMessage
()));
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/jh/boot/security/api/Signup.java
View file @
8ef38747
...
...
@@ -4,6 +4,8 @@ public class Signup {
private
String
login
;
private
String
email
;
private
String
password
;
private
Boolean
terms
;
...
...
@@ -20,6 +22,13 @@ public class Signup {
this
.
password
=
password
;
}
public
Signup
(
String
login
,
String
email
,
String
password
)
{
super
();
this
.
login
=
login
;
this
.
email
=
email
;
this
.
password
=
password
;
}
public
String
getLogin
()
{
return
login
;
}
...
...
@@ -52,4 +61,11 @@ public class Signup {
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 {
@Override
@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
);
if
(
user
!=
null
)
{
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 {
html
=
templateService
.
evaluate
(
html
,
data
,
locale
);
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
.
setText
(
content
);
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