Beispiel #1
0
func LoginUser(paramMap map[string]string) model.User {
	params := []string{paramMap["Email"], util.MD5(paramMap["Password"])}
	rows := db.Execute(len(params), params, db.UserQ("CheckLoginDetails"))
	var id int64
	var age int32
	var email, password, name, auth_token, utype string
	var users []model.User
	for rows.Next() {
		err := rows.Scan(&id, &email, &password, &name, &age, &auth_token, &utype)
		if err != nil {
			log.Fatal(err)
		}
		users = append(users, model.User{id, email, name, age, auth_token, utype, ""})
	}
	return users[0]
}
Beispiel #2
0
func CreateUser(paramMap map[string]string) (string, int64) {
	token := authToken(paramMap["Email"], paramMap["Name"])
	params := []string{paramMap["Email"],
		util.MD5(paramMap["Password"]),
		paramMap["Name"],
		paramMap["BirthYear"],
		token,
		"passenger", ""}
	var ids []int64
	var userId int64
	rows := db.Execute(len(params), params, db.UserQ("CreateUser"))
	for rows.Next() {
		err := rows.Scan(&userId)
		if err != nil {
			log.Fatal(err)
		}
		ids = append(ids, userId)
	}

	paramMap["AuthToken"] = token
	UpdateUser(paramMap)
	return token, ids[0]
}
Beispiel #3
0
func authToken(email string, name string) string {
	return util.MD5(strings.Join([]string{email}, name))
}