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
ac125b9b
Commit
ac125b9b
authored
5 years ago
by
Jan Hrabal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
terms
parent
756ea1b4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
26 deletions
+88
-26
data.sql
sql/data.sql
+0
-0
init.sql
sql/init.sql
+15
-0
LegalDocument.java
src/main/java/com/jh/boot/document/LegalDocument.java
+1
-1
LegalDocumentRepository.java
...in/java/com/jh/boot/document/LegalDocumentRepository.java
+40
-0
LegalDocumentService.java
src/main/java/com/jh/boot/document/LegalDocumentService.java
+19
-0
AuthApiController.java
...main/java/com/jh/boot/security/api/AuthApiController.java
+13
-11
LegalDocumentRepository.java
.../jh/boot/security/repository/LegalDocumentRepository.java
+0
-8
LegalDocumentService.java
...va/com/jh/boot/security/service/LegalDocumentService.java
+0
-6
No files found.
sql/data.sql
View file @
ac125b9b
This diff is collapsed.
Click to expand it.
sql/init.sql
View file @
ac125b9b
...
...
@@ -206,4 +206,18 @@ CREATE TABLE CUSTOMIZABLE_TEMPLATE_LABEL (
CREATE
INDEX
CUSTOMIZABLE_TEMPLATE_LABEL_TEMPLATE_IDX
ON
CUSTOMIZABLE_TEMPLATE_LABEL
(
TEMPLATE_ID
);
CREATE
INDEX
CUSTOMIZABLE_TEMPLATE_LABEL_UNIT_IDX
ON
CUSTOMIZABLE_TEMPLATE_LABEL
(
UNIT_ID
);
-- LEGAL DOCUMENTS
CREATE
TABLE
LEGAL_DOCUMENT
(
ID
INT8
NOT
NULL
,
CODE
VARCHAR
(
1000
)
NOT
NULL
,
LOCALE
VARCHAR
(
10
),
CONTENT
VARCHAR
,
CONSTRAINT
PK_LEGAL_DOCUMENT
PRIMARY
KEY
(
ID
)
);
CREATE
INDEX
LEGAL_DOCUMENT_IDX
ON
LEGAL_DOCUMENT
(
CODE
,
LOCALE
);
-- TODO
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/
security/model
/LegalDocument.java
→
src/main/java/com/jh/boot/
document
/LegalDocument.java
View file @
ac125b9b
package
com
.
jh
.
boot
.
security
.
model
;
package
com
.
jh
.
boot
.
document
;
import
com.jh.boot.jpa.AbstractIdEntity
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/document/LegalDocumentRepository.java
0 → 100644
View file @
ac125b9b
package
com
.
jh
.
boot
.
document
;
import
javax.persistence.Query
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.util.StringUtils
;
import
com.jh.boot.jpa.AbstractHibernateRepository
;
@Repository
public
class
LegalDocumentRepository
extends
AbstractHibernateRepository
{
public
LegalDocument
findByCodeAndLocale
(
String
code
,
String
locale
)
{
if
(
code
==
null
)
{
return
null
;
}
if
(!
StringUtils
.
hasText
(
locale
))
{
locale
=
"en"
;
}
locale
=
locale
.
replace
(
"-"
,
"_"
);
Query
q
=
entityManager
.
createQuery
(
"select ld from LegalDocument ld where lower(ld.code) = :code and lower(ld.locale) = :locale"
);
q
.
setParameter
(
"code"
,
locale
.
trim
().
toLowerCase
());
q
.
setParameter
(
"locale"
,
locale
.
trim
().
toLowerCase
());
LegalDocument
ld
=
singleResult
(
q
);
if
(
ld
==
null
)
{
if
(
locale
.
indexOf
(
'_'
)
>
-
1
)
{
return
findByCodeAndLocale
(
code
,
locale
.
substring
(
0
,
locale
.
lastIndexOf
(
'_'
)));
}
else
if
(!
"en"
.
equalsIgnoreCase
(
locale
))
{
return
findByCodeAndLocale
(
code
,
"en"
);
}
}
return
null
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/document/LegalDocumentService.java
0 → 100644
View file @
ac125b9b
package
com
.
jh
.
boot
.
document
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
@Service
public
class
LegalDocumentService
{
@Autowired
private
LegalDocumentRepository
repo
;
@Transactional
public
LegalDocument
findByCodeAndLocale
(
String
code
,
String
locale
)
{
return
repo
.
findByCodeAndLocale
(
code
,
locale
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/security/api/AuthApiController.java
View file @
ac125b9b
...
...
@@ -8,8 +8,7 @@ import java.util.ArrayList;
import
java.util.Base64
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.logging.ErrorManager
;
import
java.util.Locale
;
import
javax.servlet.http.HttpSession
;
...
...
@@ -31,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
com.jh.boot.document.LegalDocument
;
import
com.jh.boot.document.LegalDocumentService
;
import
com.jh.boot.security.AppUserAuthentication
;
import
com.jh.boot.security.AuthError
;
import
com.jh.boot.security.AuthService
;
...
...
@@ -54,6 +55,10 @@ public class AuthApiController {
@Autowired
private
AuthService
authService
;
@Autowired
private
LegalDocumentService
documentService
;
@Value
(
"${auth.controller.signup.enabled:true}"
)
private
boolean
signupEnabled
;
...
...
@@ -218,20 +223,17 @@ public class AuthApiController {
}
/*
@GetMapping
(
"/auth/terms"
)
public @ResponseBody AppUser user() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth instanceof AppUserAuthentication) {
return ((AppUserAuthentication) auth).getUser();
public
@ResponseBody
LegalDocument
terms
(
Locale
locale
)
{
return
documentService
.
findByCodeAndLocale
(
"AUTH.TERMS"
,
locale
.
toLanguageTag
());
}
//TODO other auth types?
return null;
}
@GetMapping
(
"/auth/privacy"
)
public
@ResponseBody
LegalDocument
privacy
(
Locale
locale
)
{
return
documentService
.
findByCodeAndLocale
(
"AUTH.PRIVACY"
,
locale
.
toLanguageTag
());
}
*/
}
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/security/repository/LegalDocumentRepository.java
deleted
100644 → 0
View file @
756ea1b4
package
com
.
jh
.
boot
.
security
.
repository
;
import
com.jh.boot.jpa.AbstractHibernateRepository
;
public
class
LegalDocumentRepository
extends
AbstractHibernateRepository
{
}
This diff is collapsed.
Click to expand it.
src/main/java/com/jh/boot/security/service/LegalDocumentService.java
deleted
100644 → 0
View file @
756ea1b4
package
com
.
jh
.
boot
.
security
.
service
;
public
class
LegalDocumentService
{
}
This diff is collapsed.
Click to expand it.
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