コード例 #1
0
    def get_reset_password(self):
        session = Session()
        if session.get("logged_in") == " true":
            session.extend()
            return redirect("/homepage")
        if session.get("reset_password_email_verified") != "true":
            return redirect("/auth/reset_password_email_verify")

        email = session.get("email")
        password = request.form.get("password")
        from utils.format_checker import (
            password_checker
        )
        password_check = password_checker(password)
        if not password_check:
            return {"status": False, "message": "Bad password format"}
        hashed_pwd = MD5Helper.hash(password)
        User.update(password=hashed_pwd).where(User.email == email).execute()
コード例 #2
0
def auth_discord_callback():
    if request.values.get('error'):
        return request.values['error']

    if 'state' not in session:
        raise APIError('No State', 400)

    discord = make_discord_session(state=session['state'])
    token = discord.fetch_token(
        current_app.config['DISCORD_TOKEN_URL'],
        client_secret=current_app.config['DISCORD_CLIENT_SECRET'],
        authorization_response=request.url)

    discord = make_discord_session(token=token)

    data = discord.get(current_app.config['DISCORD_API_BASE_URL'] +
                       '/users/@me').json()

    user = User.with_id(data['id'])

    if not user:
        User.create(
            user_id=data['id'],
            username=data['username'],
            discriminator=data['discriminator'],
            avatar=data['avatar'],
            bot=False,
        )
    else:
        User.update(
            username=data['username'],
            discriminator=data['discriminator'],
            avatar=data['avatar'],
        ).where(User.user_id == data['id']).execute()

    g.user = user
    return redirect('/')
コード例 #3
0
ファイル: manage.py プロジェクト: ev0x/rowboat-rewrite-public
def ctl_admins_remove(user_id):
    from common.models.user import User
    User.update(admin=False).where((User.user_id == user_id)).execute()
コード例 #4
0
ファイル: manage.py プロジェクト: ev0x/rowboat-rewrite-public
def ctl_admins_add(user_id):
    from common.models.user import User
    User.update(admin=True).where((User.user_id == user_id)).execute()