Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4d2f04f4

Přidáno uživatelem Michal Schwob před asi 2 roky(ů)

Creation of administration page and user registration
re #9627

Zobrazit rozdíly:

frontend/src/features/Auth/userThunks.ts
6 6
const loginError =
7 7
    'Server error occurred while logging in. Please contact help service to resolve this issue or try again later.'
8 8

  
9
const registerError =
10
    'Server error occurred while registering. Please contact help service to resolve this issue or try again later.'
11

  
9 12
// This is not present in the swagger since spring generates
10 13
export interface UserLogin {
11 14
    username: string,
12 15
    password: string
13 16
}
14 17

  
18
export interface UserRegister {
19
    username: string,
20
    passwords: {
21
        password: string,
22
        confirmationPassword: string,
23
    },
24
    permissions: {
25
        canRead: boolean,
26
        canWrite: boolean,
27
        canDelete: boolean,
28
    },
29
    email: string,
30
}
31

  
15 32
export const logIn = createAsyncThunk(
16 33
    'user/login',
17 34
    async (userDto: UserLogin, { getState }) => {
......
50 67
        }
51 68
    }
52 69
)
70

  
71
export const register = createAsyncThunk(
72
    'user/register',
73
    async (userDto: UserRegister) => {
74
        try {
75
            console.log(userDto.passwords.password)
76
            console.log(userDto.passwords.confirmationPassword)
77
            const { data, status } = await axiosInstance.post('/users', userDto)
78
            if (status !== 200) {
79
                // TODO read API err
80
                return Promise.reject(loginError)
81
            }
82
            return status
83
        } catch (err: any) {
84
            return Promise.reject(loginError)
85
        }
86
    }
87
)

Také k dispozici: Unified diff