Add subcommand to find a user

This commit is contained in:
Andrew-71 2024-10-13 14:49:41 +03:00
parent c22cf9e7c8
commit 452048359a
5 changed files with 47 additions and 7 deletions

View file

@ -18,6 +18,7 @@ func validPass(pass string) bool {
return len(pass) >= 8
}
// Register creates a new user with credentials provided through Basic Auth
func Register(w http.ResponseWriter, r *http.Request, data storage.Storage) {
email, password, ok := r.BasicAuth()
@ -48,6 +49,7 @@ func Register(w http.ResponseWriter, r *http.Request, data storage.Storage) {
http.Error(w, "This API requires authorization", http.StatusUnauthorized)
}
// Login returns JWT for a registered user through Basic Auth
func Login(w http.ResponseWriter, r *http.Request, data storage.Storage) {
email, password, ok := r.BasicAuth()

View file

@ -16,9 +16,7 @@ import (
"github.com/golang-jwt/jwt/v5"
)
var (
key *rsa.PrivateKey
)
var key *rsa.PrivateKey
// LoadKey attempts to load a private key from KeyFile.
// If the file does not exist, it generates a new key (and saves it)