Skip to content

Commit

Permalink
Add auth with usr type model (#24)
Browse files Browse the repository at this point in the history
* Add mongo db support

* rename Auth model

* Create auth with user type model to store role of user

* Add user id

* Minor update

* Fix detekt build fail
  • Loading branch information
Harsh3305 authored Jul 14, 2023
1 parent 3cb3c54 commit 21aea5d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ dependencies {
testImplementation("io.projectreactor:reactor-test")
// Detekt plugins
detektPlugins ("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.0")
// User Model
// HRV-Mart
implementation("com.hrv.mart:user-library:0.0.3")
// API-Call
implementation("com.hrv.mart:api-call:0.0.3")
// Mongo-DB
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
}

tasks.withType<KotlinCompile> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ package com.hrv.mart.authlibrary.model

import com.hrv.mart.userlibrary.model.User

data class Auth (
data class AppWriteAuth (
val userId: String,
val createdAt: String,
val updatedAt: String,
val name: String,
val email: String,
val emailVerification: Boolean,
val userType: UserType = UserType.USER
val emailVerification: Boolean
) {
fun toUser() =
User(
emailId = email,
name = name
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.hrv.mart.authlibrary.model
data class AuthResponse (
val userId: String,
val userType: UserType
)
)
17 changes: 17 additions & 0 deletions src/main/kotlin/com/hrv/mart/authlibrary/model/AuthWithUserType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.hrv.mart.authlibrary.model

import org.springframework.data.mongodb.core.mapping.Document

@Document
data class AuthWithUserType (
val userId: String,
val userType: UserType
) {
companion object {
fun parseFrom(auth: AppWriteAuth, userType: UserType) =
AuthWithUserType(
userId = auth.userId,
userType = userType
)
}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/com/hrv/mart/authlibrary/model/UserType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.hrv.mart.authlibrary.model

enum class UserType {
USER, ADMIN
}
}

0 comments on commit 21aea5d

Please sign in to comment.