1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-20 03:17:04 +00:00

New Context.SetLogoutFunc/Logout and SetFunc/CallFunc methods

Read HISTORY.md
This commit is contained in:
Gerasimos (Makis) Maropoulos
2020-10-12 02:07:04 +03:00
parent 2d62d49fdb
commit f6905a3f79
13 changed files with 576 additions and 8 deletions

View File

@@ -37,6 +37,8 @@ func newApp() *iris.Application {
// http://localhost:8080/admin/settings
needAuth.Get("/settings", h)
needAuth.Get("/logout", logout)
}
return app
@@ -55,3 +57,11 @@ func h(ctx iris.Context) {
ctx.Writef("%s %s:%s", ctx.Path(), username, password)
}
func logout(ctx iris.Context) {
err := ctx.Logout() // fires 401, invalidates the basic auth.
if err != nil {
ctx.Application().Logger().Errorf("Logout error: %v", err)
}
ctx.Redirect("/admin", iris.StatusTemporaryRedirect)
}