Add utilisateur nav menu

This commit is contained in:
Chteufleur 2015-11-01 16:51:21 +01:00
parent a4473eb283
commit 87d78fa64b
7 changed files with 44 additions and 2 deletions

View File

@ -17,6 +17,11 @@ type AddTempController struct {
} }
func (c *AddTempController) Prepare() { func (c *AddTempController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess != nil {
c.Data["IsAuthentificated"] = true
}
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }

View File

@ -28,6 +28,11 @@ type MainController struct {
} }
func (c *MainController) Prepare() { func (c *MainController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess != nil {
c.Data["IsAuthentificated"] = true
}
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }

View File

@ -23,6 +23,13 @@ type ViewRelayController struct {
} }
func (c *ViewRelayController) Prepare() { func (c *ViewRelayController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess == nil {
c.Redirect(variables.LoginRoute, 302)
} else {
c.Data["IsAuthentificated"] = true
}
c.Data["IsViewRelay"] = true; c.Data["IsViewRelay"] = true;
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }
@ -76,7 +83,10 @@ type AddRelayController struct {
} }
func (c *AddRelayController) Prepare() { func (c *AddRelayController) Prepare() {
c.Data["version"] = variables.Version sess := c.GetSession(variables.SessionName)
if sess == nil {
c.Redirect(variables.LoginRoute, 302)
}
} }
func (c *AddRelayController) Get() { func (c *AddRelayController) Get() {
@ -98,6 +108,12 @@ type CommandRelayController struct {
beego.Controller beego.Controller
} }
func (c *CommandRelayController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess == nil {
c.Redirect(variables.LoginRoute, 302)
}
}
func (c *CommandRelayController) Post() { func (c *CommandRelayController) Post() {
mac := c.Ctx.Input.Param(":sensor") mac := c.Ctx.Input.Param(":sensor")

View File

@ -20,6 +20,8 @@ func (c *SensorsController) Prepare() {
sess := c.GetSession(variables.SessionName) sess := c.GetSession(variables.SessionName)
if sess == nil { if sess == nil {
c.Redirect(variables.LoginRoute, 302) c.Redirect(variables.LoginRoute, 302)
} else {
c.Data["IsAuthentificated"] = true
} }
c.Data["IsSensor"] = true c.Data["IsSensor"] = true

View File

@ -15,9 +15,11 @@ func (c *UserController) Prepare() {
sess := c.GetSession(variables.SessionName) sess := c.GetSession(variables.SessionName)
if sess == nil { if sess == nil {
c.Redirect(variables.LoginRoute, 302) c.Redirect(variables.LoginRoute, 302)
} else {
c.Data["IsAuthentificated"] = true
} }
// c.Data["IsSensor"] = true c.Data["IsUser"] = true
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }

View File

@ -16,6 +16,11 @@ type ViewTempController struct {
} }
func (c *ViewTempController) Prepare() { func (c *ViewTempController) Prepare() {
sess := c.GetSession(variables.SessionName)
if sess != nil {
c.Data["IsAuthentificated"] = true
}
c.Data["IsViewTemp"] = true c.Data["IsViewTemp"] = true
c.Data["version"] = variables.Version c.Data["version"] = variables.Version
} }

View File

@ -31,6 +31,13 @@
><a href="/view/elec">Consommation electrique</a></li> --> ><a href="/view/elec">Consommation electrique</a></li> -->
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{{if .IsAuthentificated}}
<li
{{if .IsUser}}
class="active"
{{end}}
><a href="/user">Utilisateur</a></li>
{{end}}
<li <li
{{if .IsSensor}} {{if .IsSensor}}
class="active" class="active"