Пример #1
0
func (this *LoginController) setSessionFromUser(user map[string]interface{}) rpc.JsonResult {
	loginRet := rpc.JsonResult{}
	role, ok := user["role"]
	if !ok {
		loginRet.Ret = "faild"
		loginRet.Result = "获取权限失败"
		return loginRet
	}
	sn, ok := user["sn"]
	if !ok {
		loginRet.Ret = "faild"
		loginRet.Result = "获取权限失败"
		return loginRet
	}
	department, ok := user["department"]
	if !ok {
		loginRet.Ret = "faild"
		loginRet.Result = "获取权限失败"
		return loginRet
	}
	name, ok := user[s.Name]
	if !ok {
		loginRet.Ret = "faild"
		loginRet.Result = "获取权限失败"
		return loginRet
	}
	this.SetSession(SessionUserRole, role)
	this.SetSession(SessionUserSn, sn)
	this.SetSession(SessionUserName, name)
	this.SetSession(SessionUserDepartment, department)
	loginRet.Ret = "success"
	loginRet.Result = "登录成功"
	return loginRet
}