mirror of
https://github.com/go-shiori/shiori.git
synced 2025-01-17 05:17:59 +08:00
18 lines
435 B
Go
18 lines
435 B
Go
|
package context
|
||
|
|
||
|
import "github.com/go-shiori/shiori/internal/model"
|
||
|
|
||
|
// UserIsLogged returns a boolean indicating if the user is authenticated or not
|
||
|
func (c *Context) UserIsLogged() bool {
|
||
|
_, exists := c.Get(model.ContextAccountKey)
|
||
|
return exists
|
||
|
}
|
||
|
|
||
|
func (c *Context) GetAccount() *model.Account {
|
||
|
if c.account == nil && c.UserIsLogged() {
|
||
|
c.account = c.MustGet(model.ContextAccountKey).(*model.Account)
|
||
|
}
|
||
|
|
||
|
return c.account
|
||
|
}
|