Add a user page to change password
This commit is contained in:
parent
4f0f2a6006
commit
32df6b8690
|
|
@ -12,4 +12,4 @@ SessionProvider = memory
|
||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
SessionHashFunc = sha1
|
SessionHashFunc = sha1
|
||||||
SessionHashKey = chucknorriswillkickyourassandeatyoursoul
|
SessionHashKey = chucknorriswillkickyourassandeatyoursoul
|
||||||
SessionCookieLifeTime = 60
|
SessionCookieLifeTime = 3600
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import (
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
|
"datahouse/models/sensor"
|
||||||
"datahouse/models/temperature"
|
"datahouse/models/temperature"
|
||||||
temperatureTmp "datahouse/models/temperature/temp"
|
temperatureTmp "datahouse/models/temperature/temp"
|
||||||
"datahouse/models/sensor"
|
|
||||||
"datahouse/models/variables"
|
"datahouse/models/variables"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ var (
|
||||||
_, timezoneOffset = time.Now().Zone()
|
_, timezoneOffset = time.Now().Zone()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type SensorPrint struct {
|
type SensorPrint struct {
|
||||||
Name string
|
Name string
|
||||||
Mac string
|
Mac string
|
||||||
|
|
@ -37,8 +36,7 @@ func (c *MainController) Get() {
|
||||||
c.TplNames = "index.tpl"
|
c.TplNames = "index.tpl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLastTemps() []SensorPrint {
|
||||||
func getLastTemps() ([]SensorPrint) {
|
|
||||||
sensors := sensor.GetAllSensor()
|
sensors := sensor.GetAllSensor()
|
||||||
var values []SensorPrint
|
var values []SensorPrint
|
||||||
for _, s := range sensors {
|
for _, s := range sensors {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ func (c *LoginController) Prepare() {
|
||||||
func (c *LoginController) Get() {
|
func (c *LoginController) Get() {
|
||||||
sess := c.GetSession(variables.SessionName)
|
sess := c.GetSession(variables.SessionName)
|
||||||
if sess != nil {
|
if sess != nil {
|
||||||
c.Redirect(variables.RootRoute, 302)
|
c.Redirect(variables.UserRoute, 302)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -39,13 +39,10 @@ func (c *LoginController) Post() {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.SetSession(variables.SessionName, login)
|
c.SetSession(variables.SessionName, login)
|
||||||
c.Redirect(variables.RootRoute, 302)
|
c.Redirect(variables.UserRoute, 302)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isLoginOK(lgn, pwd string) bool {
|
||||||
|
|
||||||
|
|
||||||
func isLoginOK(lgn, pwd string) (bool) {
|
|
||||||
ret := pwd != "" // Do not authorize empty password
|
ret := pwd != "" // Do not authorize empty password
|
||||||
usr := user.GetUserByLogin(lgn)
|
usr := user.GetUserByLogin(lgn)
|
||||||
return ret && pwd == usr.Password
|
return ret && pwd == usr.Password
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"datahouse/models/temperature"
|
"datahouse/models/temperature"
|
||||||
"datahouse/models/variables"
|
"datahouse/models/variables"
|
||||||
|
|
||||||
"strconv"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SensorsController struct {
|
type SensorsController struct {
|
||||||
|
|
@ -25,7 +25,6 @@ func (c *SensorsController) Prepare() {
|
||||||
c.Data["version"] = variables.Version
|
c.Data["version"] = variables.Version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *SensorsController) Get() {
|
func (c *SensorsController) Get() {
|
||||||
sensors := sensor.GetAllSensor()
|
sensors := sensor.GetAllSensor()
|
||||||
|
|
||||||
|
|
@ -33,7 +32,6 @@ func (c *SensorsController) Get() {
|
||||||
c.TplNames = "sensors.tpl"
|
c.TplNames = "sensors.tpl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *SensorsController) Post() {
|
func (c *SensorsController) Post() {
|
||||||
description := c.Input().Get("description")
|
description := c.Input().Get("description")
|
||||||
mac := c.Input().Get("mac")
|
mac := c.Input().Get("mac")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
|
"datahouse/models/user"
|
||||||
|
"datahouse/models/variables"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserController struct {
|
||||||
|
beego.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserController) Prepare() {
|
||||||
|
sess := c.GetSession(variables.SessionName)
|
||||||
|
if sess == nil {
|
||||||
|
c.Redirect(variables.LoginRoute, 302)
|
||||||
|
}
|
||||||
|
|
||||||
|
// c.Data["IsSensor"] = true
|
||||||
|
c.Data["version"] = variables.Version
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserController) Get() {
|
||||||
|
c.TplNames = "user.tpl"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *UserController) Post() {
|
||||||
|
pwd1 := c.Input().Get("password1")
|
||||||
|
pwd2 := c.Input().Get("password2")
|
||||||
|
|
||||||
|
if pwd1 == pwd2 {
|
||||||
|
login := c.GetSession(variables.SessionName)
|
||||||
|
switch lo := login.(type) {
|
||||||
|
case string:
|
||||||
|
user.ChangePassword(lo, pwd1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Redirect(variables.UserRoute, 302)
|
||||||
|
}
|
||||||
|
|
@ -3,16 +3,14 @@ package controllers
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
|
|
||||||
"datahouse/models/temperature"
|
|
||||||
"datahouse/models/sensor"
|
"datahouse/models/sensor"
|
||||||
|
"datahouse/models/temperature"
|
||||||
"datahouse/models/variables"
|
"datahouse/models/variables"
|
||||||
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type ViewTempController struct {
|
type ViewTempController struct {
|
||||||
beego.Controller
|
beego.Controller
|
||||||
}
|
}
|
||||||
|
|
@ -41,12 +39,10 @@ func (c *ViewTempController) Get() {
|
||||||
c.TplNames = "temp.tpl"
|
c.TplNames = "temp.tpl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
func formatDataSensor(sensorName string, values []temperature.TempTable) string {
|
func formatDataSensor(sensorName string, values []temperature.TempTable) string {
|
||||||
ret := "{name : \"" + sensorName + "\", data : ["
|
ret := "{name : \"" + sensorName + "\", data : ["
|
||||||
for i := 0; i < len(values); i++ {
|
for i := 0; i < len(values); i++ {
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -1,10 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "datahouse/routers"
|
|
||||||
"datahouse/models/database"
|
"datahouse/models/database"
|
||||||
_ "datahouse/models/temperature"
|
_ "datahouse/models/temperature"
|
||||||
"datahouse/models/user"
|
"datahouse/models/user"
|
||||||
|
_ "datahouse/routers"
|
||||||
|
|
||||||
"github.com/astaxie/beego"
|
"github.com/astaxie/beego"
|
||||||
"github.com/astaxie/beego/logs"
|
"github.com/astaxie/beego/logs"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"datahouse/models/utils"
|
"datahouse/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type SensorTable struct {
|
type SensorTable struct {
|
||||||
Id int64
|
Id int64
|
||||||
SensorMAC string
|
SensorMAC string
|
||||||
|
|
@ -19,8 +18,7 @@ func init() {
|
||||||
orm.RegisterModel(new(SensorTable))
|
orm.RegisterModel(new(SensorTable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetSensorByMac(sensorMac string) *SensorTable {
|
||||||
func GetSensorByMac(sensorMac string) (*SensorTable) {
|
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -41,7 +39,7 @@ func GetSensorByMac(sensorMac string) (*SensorTable) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllSensorIds() ([]int64) {
|
func GetAllSensorIds() []int64 {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -57,7 +55,7 @@ func GetAllSensorIds() ([]int64) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllSensor() ([]SensorTable) {
|
func GetAllSensor() []SensorTable {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -79,7 +77,7 @@ func GetAllSensor() ([]SensorTable) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSensor(id int64) (*SensorTable) {
|
func GetSensor(id int64) *SensorTable {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -98,7 +96,6 @@ func GetSensor(id int64) (*SensorTable) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func UpdateSensor(mac, description string, interval int64) {
|
func UpdateSensor(mac, description string, interval int64) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
@ -111,7 +108,6 @@ func UpdateSensor(mac, description string, interval int64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func AddSensor(sensorMac string) {
|
func AddSensor(sensorMac string) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,10 @@ type TempTableTmp struct {
|
||||||
Value int64
|
Value int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
orm.RegisterModel(new(TempTableTmp))
|
orm.RegisterModel(new(TempTableTmp))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the value into the database.
|
* Add the value into the database.
|
||||||
*/
|
*/
|
||||||
|
|
@ -39,8 +36,7 @@ func AddData(sensor, value int64) {
|
||||||
o.Insert(tmpTable)
|
o.Insert(tmpTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetTemp(sensorId int64) *TempTableTmp {
|
||||||
func GetTemp(sensorId int64) (*TempTableTmp) {
|
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -58,7 +54,6 @@ func GetTemp(sensorId int64) (*TempTableTmp) {
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func UpdateTemp(sensorId, val int64, date time.Time) {
|
func UpdateTemp(sensorId, val int64, date time.Time) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ func init() {
|
||||||
orm.RegisterModel(new(TempTable))
|
orm.RegisterModel(new(TempTable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the value into the database.
|
* Add the value into the database.
|
||||||
*/
|
*/
|
||||||
|
|
@ -34,7 +33,7 @@ func AddData(sensor, value int64) {
|
||||||
o.Insert(tmpTable)
|
o.Insert(tmpTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAllTempForSensor(sensorId int64) ([]TempTable) {
|
func GetAllTempForSensor(sensorId int64) []TempTable {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -55,7 +54,7 @@ func GetAllTempForSensor(sensorId int64) ([]TempTable) {
|
||||||
return dataArray
|
return dataArray
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLastTempForSensor(sensorId int64) (*TempTable) {
|
func GetLastTempForSensor(sensorId int64) *TempTable {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,18 @@ import (
|
||||||
"datahouse/models/utils"
|
"datahouse/models/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id int64
|
Id int64
|
||||||
Login string
|
Login string
|
||||||
Password string
|
Password string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// register model
|
// register model
|
||||||
orm.RegisterModel(new(User))
|
orm.RegisterModel(new(User))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsUserExist(login string) bool {
|
||||||
func IsUserExist(login string) (bool) {
|
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -38,7 +35,7 @@ func IsUserExist(login string) (bool) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUserByLogin(login string) (*User) {
|
func GetUserByLogin(login string) *User {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -56,8 +53,7 @@ func GetUserByLogin(login string) (*User) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUser(id int64) *User {
|
||||||
func GetUser(id int64) (*User) {
|
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
|
@ -75,10 +71,20 @@ func GetUser(id int64) (*User) {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func AddUser(login, sha256Pass string) {
|
func AddUser(login, sha256Pass string) {
|
||||||
o := orm.NewOrm()
|
o := orm.NewOrm()
|
||||||
o.Using(database.Alias)
|
o.Using(database.Alias)
|
||||||
|
|
||||||
_, _ = o.Insert(&User{Login: login, Password: sha256Pass})
|
_, _ = o.Insert(&User{Login: login, Password: sha256Pass})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ChangePassword(login, newPwd string) {
|
||||||
|
o := orm.NewOrm()
|
||||||
|
o.Using(database.Alias)
|
||||||
|
|
||||||
|
user := GetUserByLogin(login)
|
||||||
|
if o.Read(user) == nil {
|
||||||
|
user.Password = newPwd
|
||||||
|
o.Update(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func GetString(m orm.Params, param string) string {
|
func GetString(m orm.Params, param string) string {
|
||||||
ret := ""
|
ret := ""
|
||||||
switch i := m[param].(type) {
|
switch i := m[param].(type) {
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ var (
|
||||||
ViewTempRoute = "/view/temp"
|
ViewTempRoute = "/view/temp"
|
||||||
SensorsRoute = "/sensors"
|
SensorsRoute = "/sensors"
|
||||||
LoginRoute = "/login"
|
LoginRoute = "/login"
|
||||||
|
UserRoute = "/user"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ func init() {
|
||||||
beego.Router(variables.ViewTempRoute, &controllers.ViewTempController{})
|
beego.Router(variables.ViewTempRoute, &controllers.ViewTempController{})
|
||||||
beego.Router(variables.SensorsRoute, &controllers.SensorsController{})
|
beego.Router(variables.SensorsRoute, &controllers.SensorsController{})
|
||||||
beego.Router(variables.LoginRoute, &controllers.LoginController{})
|
beego.Router(variables.LoginRoute, &controllers.LoginController{})
|
||||||
|
beego.Router(variables.UserRoute, &controllers.UserController{})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
body {
|
||||||
|
padding-top: 40px;
|
||||||
|
padding-bottom: 40px;
|
||||||
|
/*background-color: #eee;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-signin {
|
||||||
|
max-width: 450px;
|
||||||
|
padding: 15px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
/*.form-signin .form-signin-heading,
|
||||||
|
.form-signin .checkbox {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.form-signin .checkbox {
|
||||||
|
font-weight: normal;
|
||||||
|
}*/
|
||||||
|
.form-signin .form-control {
|
||||||
|
position: relative;
|
||||||
|
height: auto;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.form-signin .form-control:focus {
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
/*.form-signin input[type="email"] {
|
||||||
|
margin-bottom: -1px;
|
||||||
|
border-bottom-right-radius: 0;
|
||||||
|
border-bottom-left-radius: 0;
|
||||||
|
}*/
|
||||||
|
.form-signin input[type="password"] {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
@ -14,3 +14,5 @@
|
||||||
<script type="text/javascript" src="/static/bootstrap/js/npm.js"></script>
|
<script type="text/javascript" src="/static/bootstrap/js/npm.js"></script>
|
||||||
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
|
||||||
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
|
<script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>
|
||||||
|
|
||||||
|
{{template "extrajs" .}}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,17 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Interval de prise de mesure : </label>
|
<label>Interval de prise de mesure : </label>
|
||||||
<input type="number" class="form-control" name="interval" value="{{$val.Interval}}"/>
|
<input type="number" class="form-control" name="interval" value="{{$val.Interval}}"/>
|
||||||
<label>secondes</label>
|
<!-- <select name="interval">
|
||||||
|
<option value="1">1</option>
|
||||||
|
<option value="2">2</option>
|
||||||
|
<option value="3">3</option>
|
||||||
|
<option value="4">4</option>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="6">6</option>
|
||||||
|
<option value="7">7</option>
|
||||||
|
<option value="8">8</option>
|
||||||
|
<option value="9">9</option>
|
||||||
|
</select> -->
|
||||||
</div>
|
</div>
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,19 @@
|
||||||
}, {
|
}, {
|
||||||
count: 1,
|
count: 1,
|
||||||
type: 'day',
|
type: 'day',
|
||||||
text: '24h'
|
text: '1j'
|
||||||
|
}, {
|
||||||
|
count: 2,
|
||||||
|
type: 'day',
|
||||||
|
text: '2j'
|
||||||
|
}, {
|
||||||
|
count: 3,
|
||||||
|
type: 'day',
|
||||||
|
text: '3j'
|
||||||
|
}, {
|
||||||
|
count: 5,
|
||||||
|
type: 'day',
|
||||||
|
text: '5j'
|
||||||
}, {
|
}, {
|
||||||
count: 7,
|
count: 7,
|
||||||
type: 'day',
|
type: 'day',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
{{template "base/base.html" .}}
|
||||||
|
|
||||||
|
{{define "meta"}}
|
||||||
|
<link href="/static/css/user.css" rel="stylesheet">
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "body"}}
|
||||||
|
<center><h2 class="form-signin-heading">Chagement de mot de passe</h2></center>
|
||||||
|
<form id="chPwdForm" class="form-signin" action="/user" method="POST">
|
||||||
|
<label for="inputEmail" class="sr-only">Mot de passe</label>
|
||||||
|
<input type="password" id="password1" name="password1" class="form-control" placeholder="Password" required>
|
||||||
|
|
||||||
|
<label for="inputPassword" class="sr-only">Mot de passe</label>
|
||||||
|
<input type="password" id="password2" name="password2" class="form-control" placeholder="Password" required>
|
||||||
|
|
||||||
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Enregistrer</button>
|
||||||
|
</form>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "extrajs"}}
|
||||||
|
<script src="/static/js/jquery.sha256.min.js"></script>
|
||||||
|
<script type="application/javascript">
|
||||||
|
$("#chPwdForm").submit(function() {
|
||||||
|
$('#password1').val($.sha256($('#password1').val()));
|
||||||
|
console.log("Password1: "+$('#password1').val());
|
||||||
|
$('#password2').val($.sha256($('#password2').val()));
|
||||||
|
console.log("Password2: "+$('#password2').val());
|
||||||
|
|
||||||
|
return $('#password1').val() == $('#password2').val();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{{end}}
|
||||||
Loading…
Reference in New Issue