controllers

package
v1.0.4-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthRequest = func(ctx *context.Context) {
	uid, ok := ctx.Input.Session(sessionName).(int)
	if !ok && ctx.Input.URI() != "/login" && ctx.Input.URI() != "/register" {
		ctx.Redirect(302, "/login")
		return
	}
	var user models.User
	var err error
	qs := orm.NewOrm()
	user.Id = uid
	err = qs.Read(&user, "Id")
	if err != nil {
		ctx.Redirect(302, "/login")
		return
	}
	qs.LoadRelated(&user, "Profile")
	ctx.Input.SetData("user", user)
}

AuthRequest "filter" to limit request based on sessionid

View Source
var DetectUserAgent = func(ctx *context.Context) {
	deviceDetector := mobiledetect.NewMobileDetect(ctx.Request, nil)
	ctx.Request.ParseForm()
	device := ""
	if len(ctx.Request.Form["device_type"]) != 0 {
		device = ctx.Request.Form["device_type"][0]
	}
	if device == "" {
		device = ctx.Input.Cookie("Device-Type")
	}
	if device == "" {
		if deviceDetector.IsMobile() {
			device = "mobile"
		}
		if deviceDetector.IsTablet() {
			device = "tablet"
		}
		if device == "" {
			device, _ = web.AppConfig.String("DefaultDevice")
			if device == "" {
				device = "desktop"
			}
		}
	}
	ctx.Output.Cookie("Device-Type", device)
	ctx.Input.SetData("device_type", device)
}

DetectUserAgent detects device type and set it into a cookie

Functions

func HasUser

func HasUser(user *models.User, username string) bool

HasUser checks if user exists in db

func VerifyPassword

func VerifyPassword(rawPwd, encodedPwd string) bool

VerifyPassword checks if pwd is correct

func VerifyUser

func VerifyUser(user *models.User, username, password string) (success bool)

VerifyUser virifies user credentials

Types

type AdminPanelController

type AdminPanelController struct {
	BaseController
}

AdminPanelController ...

type AjaxController

type AjaxController struct {
	BaseController
}

func (*AjaxController) GetImageUploadStatus

func (CTRL *AjaxController) GetImageUploadStatus()

func (*AjaxController) PostImage

func (CTRL *AjaxController) PostImage()

generic Ajax

type ArticleController

type ArticleController struct {
	BaseController
}

ArticleController ...

func (*ArticleController) Get

func (CTRL *ArticleController) Get()

Get Displays Article by id

func (*ArticleController) Post

func (CTRL *ArticleController) Post()

Post create/update article

type BaseController

type BaseController struct {
	web.Controller
	// contains filtered or unexported fields
}

BaseController Extendable

func (*BaseController) ConfigPage

func (CTRL *BaseController) ConfigPage(page string)

ConfigPage receives template name and makes basic config to render it

func (*BaseController) GetActiveAds

func (CTRL *BaseController) GetActiveAds() map[string]string

func (*BaseController) GetBlocks

func (CTRL *BaseController) GetBlocks() map[string]string

func (*BaseController) GetCache

func (CTRL *BaseController) GetCache()

GetCache set the cache connector into our controller

func (*BaseController) GetContent

func (CTRL *BaseController) GetContent() string

GetContent gets contents

func (*BaseController) GetDB

func (CTRL *BaseController) GetDB(db ...string) orm.Ormer

GetDB set the orm connector into our controller if repication activated we use slave to Slave

func (*BaseController) GetModuleMenu

func (CTRL *BaseController) GetModuleMenu() string

GetModuleMenu retrieves menu

type IndexController

type IndexController struct {
	BaseController
}

func (*IndexController) Get

func (CTRL *IndexController) Get()

Get main page

type LoginController

type LoginController struct {
	BaseController
}

LoginController ...

func (*LoginController) Login

func (CTRL *LoginController) Login()

Login authenticates the user

func (*LoginController) LoginView

func (CTRL *LoginController) LoginView()

LoginView ...

func (*LoginController) Logout

func (CTRL *LoginController) Logout()

Logout ...

func (*LoginController) Register

func (CTRL *LoginController) Register()

Register the user

func (*LoginController) RegisterView

func (CTRL *LoginController) RegisterView()

RegisterView displays register form

type ProfileController

type ProfileController struct {
	BaseController
}

ProfileController for users

func (*ProfileController) UserPanelView

func (CTRL *ProfileController) UserPanelView()

UserPanelView Display user's homepage

type UserPanelController

type UserPanelController struct {
	BaseController
}

UserPanelController ...

func (*UserPanelController) MainView

func (CTRL *UserPanelController) MainView()

MainView ...

type VendorPanelController

type VendorPanelController struct {
	BaseController
}

VendorPanelController ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL