feat: token based authentication, authenticate route, token storage

This commit is contained in:
2026-04-10 14:01:03 +02:00
parent a7cdb9efb1
commit b2244fef58
10 changed files with 251 additions and 7 deletions
@@ -39,6 +39,14 @@ type password struct {
hash []byte
}
// Declare a new AnonymousUser variable.
var AnonymousUser = &User{}
// Check if a User instance is the AnonymousUser.
func (u *User) IsAnonymous() bool {
return u == AnonymousUser
}
// The Set() method calculates the bcrypt hash of a plaintext password, and stores both
// the hash and the plaintext versions in the struct.
func (p *password) Set(plaintextPassword string) error {