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
7ee796ad
Commit
7ee796ad
authored
Jan 10, 2022
by
Ghitha Dinan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change secret
parent
dbaf13e1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
0 deletions
+82
-0
AuthController.kt
.../kemenag/madrasah/pmrms/auth/controller/AuthController.kt
+6
-0
ForgotPasswordRequest.kt
...ah/pmrms/auth/model/request/auth/ForgotPasswordRequest.kt
+12
-0
UsersForgotPassword.kt
...o/kemenag/madrasah/pmrms/auth/pojo/UsersForgotPassword.kt
+32
-0
UserForgotPasswordRepository.kt
...sah/pmrms/auth/repository/UserForgotPasswordRepository.kt
+11
-0
AuthService.kt
.../id/go/kemenag/madrasah/pmrms/auth/service/AuthService.kt
+21
-0
No files found.
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/controller/AuthController.kt
View file @
7ee796ad
package
id.go.kemenag.madrasah.pmrms.auth.controller
package
id.go.kemenag.madrasah.pmrms.auth.controller
import
id.go.kemenag.madrasah.pmrms.auth.model.request.auth.ForgotPasswordRequest
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
import
id.go.kemenag.madrasah.pmrms.auth.service.AuthService
import
id.go.kemenag.madrasah.pmrms.auth.service.AuthService
...
@@ -22,6 +23,11 @@ class AuthController {
...
@@ -22,6 +23,11 @@ class AuthController {
return
service
.
login
(
request
)
return
service
.
login
(
request
)
}
}
@PostMapping
(
value
=
[
"forgot-password"
],
produces
=
[
"application/json"
])
fun
forgotPassword
(
@Valid
@RequestBody
request
:
ForgotPasswordRequest
):
ResponseEntity
<
ReturnData
>
{
return
service
.
forgotPassword
(
request
)
}
@GetMapping
(
value
=
[
"detail"
],
produces
=
[
"application/json"
])
@GetMapping
(
value
=
[
"detail"
],
produces
=
[
"application/json"
])
fun
detail
():
ResponseEntity
<
ReturnData
>
{
fun
detail
():
ResponseEntity
<
ReturnData
>
{
return
service
.
detail
()
return
service
.
detail
()
...
...
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/model/request/auth/ForgotPasswordRequest.kt
0 → 100644
View file @
7ee796ad
package
id.go.kemenag.madrasah.pmrms.auth.model.request.auth
import
id.go.kemenag.madrasah.pmrms.auth.constant.VALIDATOR_MSG_REQUIRED
import
id.go.kemenag.madrasah.pmrms.auth.validator.EmailValidator
import
javax.validation.constraints.NotEmpty
class
ForgotPasswordRequest
(
@field
:
NotEmpty
(
message
=
"Email $VALIDATOR_MSG_REQUIRED"
)
@field
:
EmailValidator
var
email
:
String
?
=
null
)
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/pojo/UsersForgotPassword.kt
0 → 100644
View file @
7ee796ad
package
id.go.kemenag.madrasah.pmrms.auth.pojo
import
com.fasterxml.jackson.annotation.JsonFormat
import
com.fasterxml.jackson.annotation.JsonIgnore
import
java.util.*
import
javax.persistence.Column
import
javax.persistence.Entity
import
javax.persistence.Id
import
javax.persistence.Table
@Entity
@Table
(
name
=
"users_forgot_password"
,
schema
=
"auth"
)
data class
UsersForgotPassword
(
@Id
@Column
(
name
=
"id"
)
var
id
:
String
?
=
UUID
.
randomUUID
().
toString
(),
@Column
(
name
=
"user_id"
)
var
userId
:
String
?
=
null
,
@Column
(
name
=
"created_at"
)
@get
:
JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"dd-MM-yyyy HH:mm:ss"
,
timezone
=
"GMT+7"
)
var
createdAt
:
Date
?
=
Date
(),
@Column
(
name
=
"updated_at"
)
@get
:
JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"dd-MM-yyyy HH:mm:ss"
,
timezone
=
"GMT+7"
)
var
updatedAt
:
Date
?
=
Date
(),
@Column
(
name
=
"active"
)
@JsonIgnore
var
active
:
Boolean
?
=
true
)
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/repository/UserForgotPasswordRepository.kt
0 → 100644
View file @
7ee796ad
package
id.go.kemenag.madrasah.pmrms.auth.repository
import
id.go.kemenag.madrasah.pmrms.auth.pojo.UsersForgotPassword
import
org.springframework.data.jpa.repository.JpaRepository
import
java.util.*
interface
UserForgotPasswordRepository
:
JpaRepository
<
UsersForgotPassword
,
String
>
{
fun
findByIdAndActive
(
id
:
String
?,
active
:
Boolean
=
true
):
Optional
<
UsersForgotPassword
>
}
src/main/kotlin/id/go/kemenag/madrasah/pmrms/auth/service/AuthService.kt
View file @
7ee796ad
...
@@ -12,10 +12,13 @@ import id.go.kemenag.madrasah.pmrms.auth.exception.BadRequestException
...
@@ -12,10 +12,13 @@ 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.getUserLogin
import
id.go.kemenag.madrasah.pmrms.auth.helpers.responseNotFound
import
id.go.kemenag.madrasah.pmrms.auth.helpers.responseNotFound
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.ForgotPasswordRequest
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
import
id.go.kemenag.madrasah.pmrms.auth.model.response.jwt.JwtAuthenticationResponse
import
id.go.kemenag.madrasah.pmrms.auth.model.response.jwt.JwtAuthenticationResponse
import
id.go.kemenag.madrasah.pmrms.auth.pojo.Users
import
id.go.kemenag.madrasah.pmrms.auth.pojo.Users
import
id.go.kemenag.madrasah.pmrms.auth.pojo.UsersForgotPassword
import
id.go.kemenag.madrasah.pmrms.auth.repository.UserForgotPasswordRepository
import
id.go.kemenag.madrasah.pmrms.auth.repository.UserRepository
import
id.go.kemenag.madrasah.pmrms.auth.repository.UserRepository
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.beans.factory.annotation.Autowired
import
org.springframework.http.ResponseEntity
import
org.springframework.http.ResponseEntity
...
@@ -29,6 +32,9 @@ class AuthService {
...
@@ -29,6 +32,9 @@ class AuthService {
@Autowired
@Autowired
private
lateinit
var
repoUser
:
UserRepository
private
lateinit
var
repoUser
:
UserRepository
@Autowired
private
lateinit
var
repoUserForgotPassword
:
UserForgotPasswordRepository
fun
login
(
request
:
LoginRequest
):
ResponseEntity
<
ReturnData
>
{
fun
login
(
request
:
LoginRequest
):
ResponseEntity
<
ReturnData
>
{
try
{
try
{
val
data
=
repoUser
.
findByEmailAndActive
(
request
.
email
)
val
data
=
repoUser
.
findByEmailAndActive
(
request
.
email
)
...
@@ -77,4 +83,19 @@ class AuthService {
...
@@ -77,4 +83,19 @@ class AuthService {
throw
e
throw
e
}
}
}
}
fun
forgotPassword
(
request
:
ForgotPasswordRequest
):
ResponseEntity
<
ReturnData
>
{
try
{
val
data
=
repoUser
.
findByEmailAndActive
(
request
.
email
)
if
(
data
.
isPresent
)
{
val
userForgotPassword
=
UsersForgotPassword
()
userForgotPassword
.
userId
=
data
.
get
().
id
repoUserForgotPassword
.
save
(
userForgotPassword
)
return
responseSuccess
()
}
return
responseNotFound
(
"User $VALIDATOR_MSG_NOT_FOUND"
)
}
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