Expose errors
parent: tbd commit: 6b2125c
1 | use Error; |
2 | use Error; |
3 | |
4 | use crate |
5 | AuthenticationTokenRequest, RegisterAccountRequest, TokenExtensionRequest, |
6 | ; |
7 | use crate; |
8 | use crate; |
9 | |
10 | use ConnectionState; |
11 | |
12 | |
13 | pub async |
14 | message_type: &str, |
15 | message: &NetworkMessage, |
16 | state: &ConnectionState, |
17 | |
18 | match message_type |
19 | "&giterated_daemon::messages::authentication::RegisterAccountRequest" => |
20 | register_account_request |
21 | .handle_message |
22 | .await?; |
23 | |
24 | Ok |
25 | |
26 | "&giterated_daemon::messages::authentication::AuthenticationTokenRequest" => |
27 | authentication_token_request |
28 | .handle_message |
29 | .await?; |
30 | |
31 | Ok |
32 | |
33 | "&giterated_daemon::messages::authentication::TokenExtensionRequest" => |
34 | token_extension_request |
35 | .handle_message |
36 | .await?; |
37 | |
38 | Ok |
39 | |
40 | _ => Ok, |
41 | |
42 | |
43 | |
44 | async |
45 | State | : ,
46 | Message | : ,
47 | instance: AuthenticatedInstance, |
48 | |
49 | if *instance.inner != connection_state.instance |
50 | return Err; |
51 | |
52 | |
53 | let mut user_backend = connection_state.user_backend.lock .await; |
54 | |
55 | let response = user_backend |
56 | .register |
57 | .await |
58 | .map_err?; |
59 | drop; |
60 | |
61 | connection_state |
62 | .send |
63 | .await |
64 | .map_err?; |
65 | |
66 | Ok |
67 | |
68 | |
69 | async |
70 | State | : ,
71 | Message | : ,
72 | instance: AuthenticatedInstance, |
73 | |
74 | let issued_for = instance.inner .clone; |
75 | |
76 | let mut token_granter = connection_state.auth_granter.lock .await; |
77 | |
78 | let response = token_granter |
79 | .token_request |
80 | .await |
81 | .map_err?; |
82 | |
83 | connection_state |
84 | .send |
85 | .await |
86 | .map_err?; |
87 | |
88 | Ok |
89 | |
90 | |
91 | async |
92 | State | : ,
93 | Message | : ,
94 | instance: AuthenticatedInstance, |
95 | |
96 | let issued_for = instance.inner .clone; |
97 | |
98 | let mut token_granter = connection_state.auth_granter.lock .await; |
99 | |
100 | let response = token_granter |
101 | .extension_request |
102 | .await |
103 | .map_err?; |
104 | |
105 | connection_state |
106 | .send |
107 | .await |
108 | .map_err?; |
109 | |
110 | Ok |
111 | |
112 | |
113 | |
114 | |
115 | |
116 | InvalidRequest, |
117 | |
118 | SameInstance, |
119 | |
120 | Registration, |
121 | |
122 | Sending, |
123 | |
124 | TokenIssuance, |
125 | |
126 |