Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PMRMS Auth
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ghitha Dinan
PMRMS Auth
Commits
e3d90af5
Commit
e3d90af5
authored
Jan 10, 2022
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add role user
parent
40e15017
Pipeline
#401
canceled with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
5 deletions
+66
-5
FileConstant.kt
...d/go/kemenag/madrasah/pmrms/auth/constant/FileConstant.kt
+8
-0
SecurityConstant.kt
.../kemenag/madrasah/pmrms/auth/constant/SecurityConstant.kt
+1
-1
AuthController.kt
...o/kemenag/madrasah/pmrms/auth/contoller/AuthController.kt
+6
-4
Helpers.kt
...tlin/id/go/kemenag/madrasah/pmrms/auth/helpers/Helpers.kt
+42
-0
AuthService.kt
.../id/go/kemenag/madrasah/pmrms/auth/service/AuthService.kt
+9
-0
No files found.
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/constant/FileConstant.kt
0 → 100644
View file @
e3d90af5
package
id.go.kemenag.madrasah.pmrms.auth.constant
import
java.io.File
const
val
ROOT_DIR
=
"D:\\app-files\\pmrms\\files\\"
val
UPLOAD_DIR
=
"${ROOT_DIR}uploads${File.separator}"
val
UPLOAD_USER_DIR
=
"${UPLOAD_DIR}users"
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/constant/SecurityConstant.kt
View file @
e3d90af5
...
@@ -14,5 +14,5 @@ val USER_ADMIN_ALLOWED_PATH =
...
@@ -14,5 +14,5 @@ val USER_ADMIN_ALLOWED_PATH =
)
)
val
AUDIENCE_FILTER_PATH
=
mapOf
(
val
AUDIENCE_FILTER_PATH
=
mapOf
(
"admin"
to
USER_ADMIN_ALLOWED_PATH
"
user-
admin"
to
USER_ADMIN_ALLOWED_PATH
)
)
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/contoller/AuthController.kt
View file @
e3d90af5
...
@@ -5,10 +5,7 @@ import id.go.kemenag.madrasah.pmrms.auth.model.response.ReturnData
...
@@ -5,10 +5,7 @@ import id.go.kemenag.madrasah.pmrms.auth.model.response.ReturnData
import
id.go.kemenag.madrasah.pmrms.auth.service.AuthService
import
id.go.kemenag.madrasah.pmrms.auth.service.AuthService
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.http.ResponseEntity
import
org.springframework.http.ResponseEntity
import
org.springframework.web.bind.annotation.PostMapping
import
org.springframework.web.bind.annotation.*
import
org.springframework.web.bind.annotation.RequestBody
import
org.springframework.web.bind.annotation.RequestMapping
import
org.springframework.web.bind.annotation.RestController
import
javax.validation.Valid
import
javax.validation.Valid
@RestController
@RestController
...
@@ -22,4 +19,9 @@ class AuthController {
...
@@ -22,4 +19,9 @@ class AuthController {
fun
login
(
@Valid
@RequestBody
request
:
LoginRequest
):
ResponseEntity
<
ReturnData
>
{
fun
login
(
@Valid
@RequestBody
request
:
LoginRequest
):
ResponseEntity
<
ReturnData
>
{
return
service
.
login
(
request
)
return
service
.
login
(
request
)
}
}
@GetMapping
(
value
=
[
"detail"
],
produces
=
[
"application/json"
])
fun
detail
():
ResponseEntity
<
ReturnData
>
{
return
service
.
detail
()
}
}
}
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/helpers/Helpers.kt
0 → 100644
View file @
e3d90af5
package
id.go.kemenag.madrasah.pmrms.auth.helpers
import
com.fasterxml.jackson.databind.DeserializationFeature
import
com.fasterxml.jackson.databind.ObjectMapper
import
id.go.kemenag.madrasah.pmrms.auth.pojo.Users
import
org.springframework.security.core.context.SecurityContextHolder
import
java.net.MalformedURLException
import
java.net.URL
import
javax.servlet.http.HttpServletRequest
fun
getUserLogin
():
Users
?
{
return
try
{
val
principal
=
SecurityContextHolder
.
getContext
().
authentication
.
principal
as
Any
val
objectMapper
=
ObjectMapper
()
objectMapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
)
objectMapper
.
readValue
(
principal
.
toString
(),
Users
::
class
.
java
)
}
catch
(
e
:
Exception
)
{
null
}
}
@Throws
(
MalformedURLException
::
class
)
fun
getBaseUrl
(
request
:
HttpServletRequest
):
String
{
try
{
val
requestURL
=
URL
(
request
.
requestURL
.
toString
())
val
port
=
if
(
requestURL
.
port
==
-
1
)
""
else
":"
+
requestURL
.
port
return
requestURL
.
protocol
+
"://"
+
requestURL
.
host
+
port
+
request
.
contextPath
+
"/"
}
catch
(
e
:
Exception
)
{
throw
e
}
}
fun
getFullUrl
(
request
:
HttpServletRequest
):
String
{
val
requestURL
=
StringBuilder
(
request
.
requestURL
.
toString
())
val
queryString
=
request
.
queryString
return
if
(
queryString
==
null
)
{
requestURL
.
toString
()
}
else
{
requestURL
.
append
(
'?'
).
append
(
queryString
).
toString
()
}
}
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/service/AuthService.kt
View file @
e3d90af5
...
@@ -8,6 +8,7 @@ import id.go.kemenag.madrasah.pmrms.auth.constant.EXPIRATION_TIME
...
@@ -8,6 +8,7 @@ import id.go.kemenag.madrasah.pmrms.auth.constant.EXPIRATION_TIME
import
id.go.kemenag.madrasah.pmrms.auth.constant.SECRET
import
id.go.kemenag.madrasah.pmrms.auth.constant.SECRET
import
id.go.kemenag.madrasah.pmrms.auth.constant.TOKEN_PREFIX
import
id.go.kemenag.madrasah.pmrms.auth.constant.TOKEN_PREFIX
import
id.go.kemenag.madrasah.pmrms.auth.exception.BadRequestException
import
id.go.kemenag.madrasah.pmrms.auth.exception.BadRequestException
import
id.go.kemenag.madrasah.pmrms.auth.helpers.getUserLogin
import
id.go.kemenag.madrasah.pmrms.auth.helpers.responseSuccess
import
id.go.kemenag.madrasah.pmrms.auth.helpers.responseSuccess
import
id.go.kemenag.madrasah.pmrms.auth.model.request.auth.LoginRequest
import
id.go.kemenag.madrasah.pmrms.auth.model.request.auth.LoginRequest
import
id.go.kemenag.madrasah.pmrms.auth.model.response.ReturnData
import
id.go.kemenag.madrasah.pmrms.auth.model.response.ReturnData
...
@@ -62,4 +63,12 @@ class AuthService {
...
@@ -62,4 +63,12 @@ class AuthService {
return
jwtres
return
jwtres
}
}
fun
detail
():
ResponseEntity
<
ReturnData
>
{
return
try
{
responseSuccess
(
data
=
repoUser
.
findByIdAndActive
(
getUserLogin
()
?.
id
))
}
catch
(
e
:
Exception
)
{
throw
e
}
}
}
}
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