File tree 2 files changed +52
-0
lines changed
2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+
3
+
4
+ let user_compact = self.user_repository.get_compact(&user_profile.user_id).await?;
5
+
6
+
7
+ */
8
+ use std:: sync:: Arc ;
9
+
10
+ use crate :: databases:: database:: { Database , Error } ;
11
+ use crate :: models:: user:: { UserAuthorization , UserId } ;
12
+ use crate :: services:: user:: DbUserRepository ;
13
+ pub struct Service {
14
+ user_repository : Arc < DbUserRepository > ,
15
+ }
16
+
17
+ impl Service {
18
+ pub fn new ( user_repository : Arc < DbUserRepository > ) -> Self {
19
+ Self { user_repository }
20
+ }
21
+
22
+ // Check user exists in database
23
+ /* pub async fn user_exists_in_database(&self, user_id: &UserId) -> {
24
+ let user_authorization = self.
25
+ } */
26
+
27
+ // Check if the user has a role with enough privilages
28
+
29
+ //Delete token from localStorage if user does not exist - FRONTEND
30
+ }
31
+
32
+ pub struct DbUserAuthorizationRepository {
33
+ database : Arc < Box < dyn Database > > ,
34
+ }
35
+
36
+ impl DbUserAuthorizationRepository {
37
+ #[ must_use]
38
+ pub fn new ( database : Arc < Box < dyn Database > > ) -> Self {
39
+ Self { database }
40
+ }
41
+
42
+ /// Get user authorization data from user id.
43
+ ///
44
+ /// # Errors
45
+ ///
46
+ /// This function will return an error if unable to get the user
47
+ /// authorization data from the database.
48
+ pub async fn get_user_authorization_from_id ( & self , user_id : & UserId ) -> Result < UserAuthorization , Error > {
49
+ self . database . get_user_authorization_from_id ( * user_id) . await
50
+ }
51
+ }
Original file line number Diff line number Diff line change 1
1
//! App services.
2
2
pub mod about;
3
3
pub mod authentication;
4
+ pub mod authorization;
4
5
pub mod category;
5
6
pub mod hasher;
6
7
pub mod proxy;
You can’t perform that action at this time.
0 commit comments