1 |
use serde::{Deserialize, Serialize};
|
2 |
|
3 |
use crate::model::authenticated::UserAuthenticationToken;
|
4 |
|
5 |
use super::InstanceAuthenticated;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
#[derive(Clone, Serialize, Deserialize)]
|
12 |
pub enum AuthenticationMessage {
|
13 |
Request(AuthenticationRequest),
|
14 |
Response(AuthenticationResponse),
|
15 |
}
|
16 |
|
17 |
#[derive(Clone, Serialize, Deserialize)]
|
18 |
pub enum AuthenticationRequest {
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
RegisterAccount(RegisterAccountRequest),
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
AuthenticationToken(AuthenticationTokenRequest),
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
TokenExtension(TokenExtensionRequest),
|
50 |
}
|
51 |
|
52 |
#[derive(Clone, Serialize, Deserialize)]
|
53 |
pub enum AuthenticationResponse {
|
54 |
RegisterAccount(RegisterAccountResponse),
|
55 |
AuthenticationToken(AuthenticationTokenResponse),
|
56 |
TokenExtension(TokenExtensionResponse),
|
57 |
}
|
58 |
|
59 |
|
60 |
#[derive(Clone, Serialize, Deserialize)]
|
61 |
pub struct RegisterAccountRequest {
|
62 |
pub username: String,
|
63 |
pub email: Option<String>,
|
64 |
pub password: String,
|
65 |
}
|
66 |
|
67 |
#[derive(Clone, Debug, Serialize, Deserialize)]
|
68 |
pub struct RegisterAccountResponse {
|
69 |
pub token: String,
|
70 |
}
|
71 |
|
72 |
|
73 |
#[derive(Clone, Serialize, Deserialize)]
|
74 |
pub struct AuthenticationTokenRequest {
|
75 |
pub username: String,
|
76 |
pub password: String,
|
77 |
}
|
78 |
|
79 |
#[derive(Clone, Serialize, Deserialize)]
|
80 |
pub struct AuthenticationTokenResponse {
|
81 |
pub token: String,
|
82 |
}
|
83 |
|
84 |
|
85 |
#[derive(Clone, Serialize, Deserialize)]
|
86 |
pub struct TokenExtensionRequest {
|
87 |
pub token: UserAuthenticationToken,
|
88 |
}
|
89 |
|
90 |
#[derive(Clone, Serialize, Deserialize)]
|
91 |
pub struct TokenExtensionResponse {
|
92 |
pub new_token: Option<String>,
|
93 |
}
|
94 |
|