created hwsauth module
This commit is contained in:
22
hwsauth/login.go
Normal file
22
hwsauth/login.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package hwsauth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.haelnorr.com/h/golib/jwt"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (auth *Authenticator[T]) Login(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request,
|
||||
model T,
|
||||
rememberMe bool,
|
||||
) error {
|
||||
|
||||
err := jwt.SetTokenCookies(w, r, auth.tokenGenerator, model.ID(), true, rememberMe, auth.SSL)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "jwt.SetTokenCookies")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user