feat: Added basic user authorization
This commit is contained in:
27
dto/auth.go
Normal file
27
dto/auth.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type LoginRequest struct {
|
||||
Login string `json:"login"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
func (l *LoginRequest) Bind(r *http.Request) error {
|
||||
if l.Login == "" {
|
||||
return errors.New("login required")
|
||||
}
|
||||
|
||||
if l.Password == "" {
|
||||
return errors.New("password required")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
}
|
||||
Reference in New Issue
Block a user