75 lines
2.3 KiB
Go
75 lines
2.3 KiB
Go
// Copyright (c) 2025 Nikolai Papin
|
|
//
|
|
// This file is part of Easywish
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
|
// the GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
package models
|
|
|
|
type Tokens struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
}
|
|
|
|
type RegistrationBeginRequest struct {
|
|
Username string `json:"username" binding:"required" validate:"username"`
|
|
Email string `json:"email" binding:"required,email"`
|
|
Password string `json:"password" binding:"required" validate:"password"`
|
|
}
|
|
|
|
type RegistrationCompleteRequest struct {
|
|
Username string `json:"username" binding:"required" validate:"username"`
|
|
VerificationCode string `json:"verification_code" binding:"required" validate:"verification_code=reg"`
|
|
Name string `json:"name" binding:"required" validate:"name"`
|
|
Birthday *string `json:"birthday"`
|
|
}
|
|
|
|
type RegistrationCompleteResponse struct {
|
|
Tokens
|
|
}
|
|
|
|
type LoginRequest struct {
|
|
Username string `json:"username" binding:"required,min=3,max=20" validate:"username"`
|
|
Password string `json:"password" binding:"required,max=100"`
|
|
TOTP *string `json:"totp"`
|
|
}
|
|
|
|
type LoginResponse struct {
|
|
Tokens
|
|
}
|
|
|
|
// TODO: length check
|
|
type RefreshRequest struct {
|
|
RefreshToken string `json:"refresh_token" binding:"required"`
|
|
}
|
|
|
|
type RefreshResponse struct {
|
|
Tokens
|
|
}
|
|
|
|
type PasswordResetBeginRequest struct {
|
|
Email string `json:"email" binding:"required,email"`
|
|
}
|
|
|
|
type PasswordResetCompleteRequest struct {
|
|
Email string `json:"email" binding:"required,email"`
|
|
VerificationCode string `json:"verification_code" binding:"required" validate:"verification_code=reset"`
|
|
NewPassword string `json:"password" binding:"required" validate:"password"`
|
|
LogOutAccounts bool `json:"log_out_accounts"`
|
|
}
|
|
|
|
type PasswordResetCompleteResponse struct {
|
|
Tokens
|
|
}
|