Example #1
0
func (p *Login) LoginauthExec(c *gin.Context) {
	tx, err := util.GetTx()
	defer dfweb.ErrorRecover(c, tx)
	if err != nil {
		panic("Get Transaction Error:" + err.Error())
	}
	json := dfweb.GetBodyJson(c)
	login := p.getLoginFromLoginId(json, tx)
	if login == nil {
		c.JSON(200, dfweb.SetErrorMessage("ユーザー IDが見つかりません"))
		return
	}
	password := json["password"]
	if password == nil {
		c.JSON(200, dfweb.SetErrorMessage("パスワードがありません"))
		return
	}
	pwd := dfweb.CreateMd5(password.(string))
	if login.GetPassword() != pwd {
		c.JSON(200, dfweb.SetErrorMessage("passwordが違います"))
		return
	}
	ctx := util.CreateContextFromLogin("loginauth", login)
	session := p.createNewSession(login, tx, ctx)
	loginInfo := p.createLoginInfo(login)
	p.addUuidCookie(c, session.GetUuid())
	c.JSON(200, dfweb.SetSingleFetchResult(loginInfo))
}
Example #2
0
func (p *Login) Insert(data map[string]interface{}) {
	p.ctx.Put("Process", "login:insert")
	entityx := entity.CreateLogin()
	var e df.Entity = entityx
	dfweb.MapToEntity(data, &e, "Login", false)
	if p.DupCheck(entityx) {
		panic("この 社員番号は既に使用されています。")
	}
	entityx.SetPassword(dfweb.CreateMd5(entityx.GetPassword()))
	_, err := bhv.LoginBhv_I.Insert(entityx, p.tx, p.ctx)
	if err != nil {
		panic("Insert Error:" + err.Error())
	}
	var ee df.Entity = entityx
	rmap := p.EntityToMap(&ee)
	p.context.JSON(200, dfweb.SetSingleFetchResult(rmap))
}
Example #3
0
func (p *Login) convertPassword(entity *entity.Login) {
	if entity.IsModifiedProperty("password") {
		entity.SetPassword(dfweb.CreateMd5(entity.GetPassword()))
	}
}