Beispiel #1
0
    def oauth_callback(self, **params):
        # TODO Handle error messages from the API. Especially those likely to
        # occur such as "access_denied" and "redirect_uri_missmatch"

        try:
            auth_session = getAuthSession(params['code'])
        except KeyError:
            # TODO Determine the best status code for this scenario
            cherrypy.response.status = 409
            data = {'error_message': '409 OAuth2 service disliked the request'}
            return render_template('error.html', data)

        email = getUserEmail(auth_session)
        cherrypy.session['auth_session'] = auth_session

        try:
            user = UserModel.objects.get(email=email)
        except UserModel.DoesNotExist:
            add_flash_message("info", "You don't got an account yet!")
            raise cherrypy.HTTPRedirect("/user/new")

        info = getUserInformation(auth_session)
        user.gravatar_id = info['gravatar_id']
        user.save()

        add_flash_message("success", "You successfully signed in!")
        cherrypy.session['user'] = user

        raise cherrypy.HTTPRedirect("/")
Beispiel #2
0
    def sign_up(self, username=None, license_agreement=None):
        if cherrypy.request.method != "POST":
            cherrypy.response.status = 405
            data = {'error_message': '405 Method not allowed'}
            return render_template('error.html', data)

        if license_agreement != 'on':
            data = {'error_message': 'Sorry män'}
            return render_template('error.html', data)

        email = getUserEmail(cherrypy.session['auth_session'])
        user = UserModel(username=username, email=email)
        user.save()

        add_flash_message("success", "You succesfully created a new account!")
        cherrypy.session.delete()
        raise cherrypy.HTTPRedirect("/")
Beispiel #3
0
    def sign_up(self, username=None, license_agreement=None):
        if cherrypy.request.method != "POST":
            cherrypy.response.status = 405
            data = {"error_message": "405 Method not allowed"}
            return render_template("error.html", data)

        if license_agreement != "on":
            data = {"error_message": "Sorry män"}
            return render_template("error.html", data)

        email = getUserEmail(cherrypy.session["auth_session"])
        user = UserModel(username=username, email=email)
        user.save()

        add_flash_message("success", "You succesfully created a new account!")
        cherrypy.session.delete()
        raise cherrypy.HTTPRedirect("/")