Files
easywish/backend/internal/models/auth.go
Nikolai Papin 8319afc7ea refactor/fix: now using pgx errors for postgres error checking instead of trying to look up the error code;
feat: implemented working custom validation;
fix: authservice begin/complete registration
2025-07-05 03:08:00 +03:00

61 lines
1.9 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,min=3,max=20" validate:"username"`
Email *string `json:"email" binding:"email"`
Password string `json:"password" binding:"required"` // TODO: password checking
}
type RegistrationCompleteRequest struct {
Username string `json:"username" binding:"required,min=3,max=20" validate:"username"`
VerificationCode string `json:"verification_code" binding:"required"`
Name string `json:"name" binding:"required,max=75"`
Birthday *string `json:"birthday"`
AvatarUrl *string `json:"avatar_url" binding:"http_url,max=255"`
}
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
}