Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I add a callback after login? #217

Open
lixh00 opened this issue Apr 2, 2022 · 1 comment
Open

Can I add a callback after login? #217

lixh00 opened this issue Apr 2, 2022 · 1 comment

Comments

@lixh00
Copy link

lixh00 commented Apr 2, 2022

Can I add a callback after login?
such as updating the last login time of the database after login.

@realbucksavage
Copy link

Yes you can!

manager := maange.NewDefaultManager()
server := server.NewDefaultServer(manager)

server.SetUserAuthorizationHandler(func(rw http.ResponseWriter, r *http.Request) (string, error) {

    var (
        ctx      = r.Context()
        username = r.FormValue("username")
        password = r.FormValue("password")
    )
    user, err := myAuthenticator.Authenticate(ctx, username, password)
    // handle error

    // update last login time in DB
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants