Example #1
0
File: devapi.go Project: coddo/gost
// ActivateAppUser is an endpoint for activating an app user
func (v *DevAPI) ActivateAppUser(params *api.Request) api.Response {
	var token, found = filter.GetStringParameter("token", params.Form)
	if !found {
		return api.BadRequest(api.ErrInvalidInput)
	}

	var err = auth.ActivateAppUser(token)
	if err != nil {
		return api.BadRequest(err)
	}

	return api.PlainTextResponse(http.StatusOK, "Account is now active")
}
Example #2
0
// KillSession deletes a session for an existing user account based on
// the session token
func (a *AuthAPI) KillSession(params *api.Request) api.Response {
	sessionToken, found := filter.GetStringParameter("token", params.Form)
	if !found || len(sessionToken) == 0 {
		return api.BadRequest(ErrTokenNotSpecified)
	}

	session, err := cookies.GetSession(sessionToken)
	if err != nil {
		return api.InternalServerError(err)
	}

	err = session.Delete()
	if err != nil {
		return api.InternalServerError(err)
	}

	return api.StatusResponse(http.StatusOK)
}