reorder files
This commit is contained in:
parent
3c1170bd87
commit
ba49afe04a
3 changed files with 113 additions and 72 deletions
|
|
@ -22,8 +22,6 @@ import (
|
|||
"git.smarteching.com/goffee/cup/utils"
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"git.smarteching.com/goffee/core/template/components"
|
||||
)
|
||||
|
||||
func Signup(c *core.Context) *core.Response {
|
||||
|
|
@ -223,6 +221,12 @@ func Signin(c *core.Context) *core.Response {
|
|||
userAgent := c.GetUserAgent()
|
||||
hashedCacheKey := utils.CreateAuthTokenHashedCacheKey(user.ID, userAgent)
|
||||
err = c.GetCache().Set(hashedCacheKey, token)
|
||||
|
||||
// delete data from old sessions
|
||||
sessionKey := fmt.Sprintf("sess_%v", userAgent)
|
||||
hashedSessionKey := utils.CreateAuthTokenHashedCacheKey(user.ID, sessionKey)
|
||||
_ = c.GetCache().Delete(hashedSessionKey)
|
||||
|
||||
if err != nil {
|
||||
c.GetLogger().Error(err.Error())
|
||||
if TemplateEnable {
|
||||
|
|
@ -448,69 +452,3 @@ func Signout(c *core.Context) *core.Response {
|
|||
"message": "signed out successfully",
|
||||
}))
|
||||
}
|
||||
|
||||
// Show basic app login
|
||||
func AppLogin(c *core.Context) *core.Response {
|
||||
|
||||
// first, include all compoments
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Card title",
|
||||
CardBody: "Loerm ipsum at deim",
|
||||
},
|
||||
}
|
||||
return c.Response.Template("login.html", tmplData)
|
||||
}
|
||||
|
||||
// Show basic app login
|
||||
func AppSession(c *core.Context) *core.Response {
|
||||
|
||||
var session = new(utils.SessionUser)
|
||||
|
||||
hassession := session.Init(c)
|
||||
|
||||
type templateData struct {
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{}
|
||||
|
||||
if hassession {
|
||||
|
||||
return c.Response.Template("appsession.html", tmplData)
|
||||
|
||||
} else {
|
||||
|
||||
return c.Response.Template("login.html", tmplData)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show basic app sample
|
||||
func AppSample(c *core.Context) *core.Response {
|
||||
|
||||
// first, include all compoments
|
||||
type templateData struct {
|
||||
PageCard components.PageCard
|
||||
}
|
||||
|
||||
// now fill data of the components
|
||||
tmplData := templateData{
|
||||
PageCard: components.PageCard{
|
||||
CardTitle: "Protected page",
|
||||
CardBody: "If you can see this page, your are loggedin",
|
||||
},
|
||||
}
|
||||
//fmt.Printf("Outside cookie user is: %s", user.Email)
|
||||
|
||||
return c.Response.Template("app.html", tmplData)
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue