Ejemplo n.º 1
0
func initData() {
	//用户等级划分:正数是普通用户,负数是管理员各种等级划分,为0则尚未注册
	if usr := GetUserByRole(-1000); usr == nil {
		if e := AddUser("*****@*****.**", "root", "root", helper.EncryptHash("rootpass", nil), -1000); e == nil {
			fmt.Println("Default Email:[email protected] ,Username:root ,Password:rootpass")
		} else {
			fmt.Printf("create root got error:%v!", e)
		}

	}
	fmt.Println("The Zenpress system has started!")
}
Ejemplo n.º 2
0
func SignupPostHandler(self *vodka.Context) error {

	data := make(map[string]interface{})

	username := self.FormEscape("username")
	password := self.FormEscape("password")
	usererr := helper.CheckUsername(username)

	if usererr == false {
		e := errors.New("Username error, Please to again")
		data["UsernameErr"] = e.Error()
		return e
	}

	passerr := helper.CheckPassword(password)
	if passerr == false {
		e := errors.New("Password error, Please to again")
		data["PasswordErr"] = e.Error()
		return e
	}

	pwd := helper.EncryptHash(password, nil)

	//now := torgo.Date(time.Now(), "Y-m-d H:i:s")

	userInfo := models.CheckUserByNickname(username)

	fmt.Println(userInfo.Nickname)

	//  检查该用户是否已经被注册
	if userInfo.Nickname == "" {

		//注册用户
		regErr := models.AddUser(username+"@insion.co", username, "", pwd, 1)
		fmt.Println("reg:s")
		fmt.Println(regErr)
		fmt.Println("reg:e ")
		//注册成功设置session
		//	self.SetSession("userid", userInfo.Id)
		//	self.SetSession("username", userInfo.Nickname)
		//	self.SetSession("userrole", userInfo.Role)
		//	self.SetSession("useremail", userInfo.Email)
		return self.Redirect(302, "/signin/")

	} else {
		e := errors.New("User already exists")
		data["UsernameErr"] = e.Error()
		return e
	}
	return self.Render(http.StatusOK, "signup.html", data)
}
Ejemplo n.º 3
0
func creatTables(Engine *xorm.Engine) error {

	if err := Engine.Sync2(new(User), new(Category), new(Node), new(Topic), new(Reply), new(Kvs), new(File)); err != nil {
		fmt.Println("Database struct sync failed")
		fmt.Println("Engine.Sync ERRORS:", err)
		return err
	} else {
		fmt.Println("Database struct sync successfully")
	}

	//用户等级划分:正数是普通用户,负数是管理员各种等级划分,为0则尚未注册
	if GetUserByRole(-1000).Role != -1000 {
		AddUser("*****@*****.**", "root", "系统默认管理员", helper.EncryptHash("rootpass", nil), -1000)
		fmt.Println("Default User:root,Password:rootpass")

		if GetAllTopic(0, 0, "id") == nil {
			//分類默認數據
			AddCategory("Category!", "This is Category!")

			AddNode("Node!", "This is Node!", 1, 1)
			SetTopic(0, 1, 1, 1, 0, "Topic Title", `<p>This is Topic!</p>`, "root", "")

		}
	}

	if GetKV("author") != "Insion" {
		SetKV("author", "Insion")
		SetKV("title", "Zenpress")
		SetKV("title_en", "Zenpress")
		SetKV("keywords", "Zenpress,")
		SetKV("description", "Zenpress,")

		SetKV("company", "Zenpress")
		SetKV("copyright", "2013 - 2015 Copyright Zenpress .All Right Reserved")
		SetKV("site_email", "*****@*****.**")

		SetKV("tweibo", "http://t.qq.com/yours")
		SetKV("sweibo", "http://weibo.com/yours")
	}
	return nil
}