This repository has been archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from javaBin/bruker-registrering
Bruker registrering
- Loading branch information
Showing
31 changed files
with
163 additions
and
179 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
.idea/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
package backend.model | ||
|
||
class Workshop(override val id: Int, val title: String, val teacherName: String) : Model | ||
import backend.dto.WorkshopDTO | ||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.Serializable | ||
import java.time.Instant | ||
|
||
@Serializable | ||
class Workshop( | ||
override val id: Int, | ||
val title: String, | ||
val description: String, | ||
@Contextual | ||
val startTime: Instant, | ||
@Contextual | ||
val endTime: Instant, | ||
val capacity: Int | ||
) : Model { | ||
constructor(id: Int, title: String, description: String) : this(id, title, description, Instant.now(), Instant.now(), 30) | ||
fun toDTO() = WorkshopDTO(title, description) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
backend/app/src/main/kotlin/backend/repository/UserOwnedRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package backend.repository | ||
|
||
import backend.config.CustomPrincipal | ||
import io.ktor.server.auth.* | ||
|
||
class UserOwnedRepository { | ||
open class UserOwnedRepository(val userId: Long) { | ||
companion object { | ||
inline fun <T, reified R: UserOwnedRepository> userContext(auth: AuthenticationContext, block: (repository: R) -> T): T { | ||
val principal = auth.principal<CustomPrincipal>() | ||
val repository = R::class.java.getDeclaredConstructor(Long::class.java).newInstance(principal!!.userId) | ||
return block(repository) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.