Exemple #1
0
 def get_auth_token(cls):
     """
     A method that returns a login token and user information in a json
     response. This should probably be called with basic authentication in
     the header. The token generated could then be used for subsequent
     requests.
     """
     return jsonify({
         'user': current_user.serialize(),
         'token': current_user.get_auth_token(),
     })
Exemple #2
0
 def get_auth_token(cls):
     """
     A method that returns a login token and user information in a json
     response. This should probably be called with basic authentication in
     the header. The token generated could then be used for subsequent
     requests.
     """
     return jsonify({
         'user': current_user.serialize(),
         'token': current_user.get_auth_token(),
     })
Exemple #3
0
    def profile(cls):
        """
        User profile
        """
        user_form = ProfileForm(obj=current_user)
        if user_form.validate_on_submit():
            cls.write(
                [current_user], {"display_name": user_form.display_name.data, "timezone": user_form.timezone.data}
            )
            flash("Your profile has been updated.")

        if request.is_xhr or request.is_json:
            return jsonify(current_user.serialize())

        return render_template("profile.jinja", user_form=user_form, active_type_name="general")
Exemple #4
0
    def profile(cls):
        """
        User profile
        """
        user_form = ProfileForm(obj=current_user)
        if user_form.validate_on_submit():
            cls.write(
                [current_user], {
                    'display_name': user_form.display_name.data,
                    'timezone': user_form.timezone.data,
                })
            flash('Your profile has been updated.')

        if request.is_xhr or request.is_json:
            return jsonify(current_user.serialize())

        return render_template('profile.jinja',
                               user_form=user_form,
                               active_type_name="general")