Fixes for authentication!
parent: tbd commit: 969964d
1 | use Error; |
2 | |
3 | use crate AuthenticatedUser; |
4 | use crate User; |
5 | use crate:: |
6 | |
7 | UserBioRequest, UserDisplayImageRequest, UserDisplayNameRequest, UserRepositoriesRequest, |
8 | UserRepositoriesResponse, |
9 | , |
10 | , |
11 | ; |
12 | |
13 | use ConnectionState; |
14 | |
15 | pub async |
16 | message_type: &str, |
17 | message: &NetworkMessage, |
18 | state: &ConnectionState, |
19 | |
20 | match message_type |
21 | "&giterated_daemon::messages::user::UserDisplayNameRequest" => |
22 | display_name.handle_message .await?; |
23 | |
24 | Ok |
25 | |
26 | "&giterated_daemon::messages::user::UserDisplayImageRequest" => |
27 | display_image.handle_message .await?; |
28 | |
29 | Ok |
30 | |
31 | "&giterated_daemon::messages::user::UserBioRequest" => |
32 | bio.handle_message .await?; |
33 | |
34 | Ok |
35 | |
36 | "&giterated_daemon::messages::user::UserRepositoriesRequest" => |
37 | repositories.handle_message .await?; |
38 | |
39 | Ok |
40 | |
41 | _ => Ok, |
42 | |
43 | |
44 | |
45 | async |
46 | Message | : ,
47 | State | : ,
48 | |
49 | let mut user_backend = connection_state.user_backend.lock .await; |
50 | let response = user_backend.display_name .await?; |
51 | |
52 | drop; |
53 | |
54 | connection_state.send .await?; |
55 | |
56 | Ok |
57 | |
58 | |
59 | async |
60 | Message | : ,
61 | State | : ,
62 | |
63 | let mut user_backend = connection_state.user_backend.lock .await; |
64 | let response = user_backend.display_image .await?; |
65 | |
66 | drop; |
67 | |
68 | connection_state.send .await?; |
69 | |
70 | Ok |
71 | |
72 | |
73 | async |
74 | Message | : ,
75 | State | : ,
76 | |
77 | let mut user_backend = connection_state.user_backend.lock .await; |
78 | let response = user_backend.bio .await?; |
79 | |
80 | drop; |
81 | |
82 | connection_state.send .await?; |
83 | |
84 | Ok |
85 | |
86 | |
87 | async |
88 | Message | : ,
89 | State | : ,
90 | requesting_user: , |
91 | |
92 | let requesting_user = requesting_user.map; |
93 | |
94 | let mut repository_backend = connection_state.repository_backend.lock .await; |
95 | let repositories = repository_backend |
96 | .repositories_for_user |
97 | .await; |
98 | |
99 | let repositories = match repositories |
100 | Ok => repositories, |
101 | Err => |
102 | error!; |
103 | return Ok; |
104 | |
105 | ; |
106 | drop; |
107 | |
108 | let mut user_backend = connection_state.user_backend.lock .await; |
109 | let user_exists = user_backend.exists .await; |
110 | |
111 | if repositories.is_empty && !matches! |
112 | return Err; |
113 | |
114 | |
115 | let response: UserRepositoriesResponse = UserRepositoriesResponse ; |
116 | |
117 | connection_state.send .await?; |
118 | |
119 | Ok |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | InvalidUser, |
126 | |
127 | Other, |
128 | |
129 |