84 lines
2.6 KiB
Go
84 lines
2.6 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 int64 `json:"birthday" validate:"birthday_unix_milli"`
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
type RefreshRequest struct {
|
|
RefreshToken string `json:"refresh_token" binding:"required,max=2000"`
|
|
}
|
|
|
|
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"`
|
|
LogOutSessions bool `json:"log_out_sessions"`
|
|
}
|
|
|
|
type PasswordResetCompleteResponse struct {
|
|
Tokens
|
|
}
|
|
|
|
type ChangePasswordRequest struct {
|
|
OldPassword string `json:"old_password" binding:"required"`
|
|
NewPassword string `json:"password" binding:"required" validate:"password"`
|
|
TOTP string `json:"totp"`
|
|
}
|
|
|
|
type ChangePasswordResponse struct {
|
|
Tokens
|
|
}
|