Add subcommand to find a user
This commit is contained in:
parent
c22cf9e7c8
commit
452048359a
5 changed files with 47 additions and 7 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue