コード例 #1
0
ファイル: japapp.go プロジェクト: adimare/japapp
// If creds are correct the user is logged in, otherwise he's redirected to the landing page
func LoginHandler(response http.ResponseWriter, request *http.Request) {
	username := request.FormValue("username")
	password := request.FormValue("password")
	redirect_target := "/index"
	if username != "" && password != "" && account.Login(username, password, response) {
		redirect_target = "/config"
	}
	http.Redirect(response, request, redirect_target, http.StatusFound)
}
コード例 #2
0
ファイル: japapp.go プロジェクト: adimare/japapp
// The user is registered and redirected to the landing page
func SignupHandler(response http.ResponseWriter, request *http.Request) {
	username := request.FormValue("username")
	password := request.FormValue("password")
	redirect_target := "/index"

	if username != "" && password != "" {
		user := models.NewUser()
		user.Fields = make(map[string]string)
		user.Fields["username"] = username
		user.Fields["password"] = password
		if _, err := account.Register(user); err == nil {
			account.Login(username, password, response)
			redirect_target = "/config"
		}
	}
	http.Redirect(response, request, redirect_target, http.StatusFound)
}