Exemplo n.º 1
0
def deleteInfo():
    if 'g-recaptcha-response' in request.args:
        g_recaptcha_response = request.args['g-recaptcha-response']
        if recaptcha.verify(g_recaptcha_response):
            u_mail = request.args['mail']
            u_password = request.args['password']
            if database.is_exist(u_mail):
                d_status, d_password = database.query_password(u_mail)
                if d_status:
                    if database.check_password(
                            u_password,
                            base64.b64decode(d_password).decode()):
                        id_status, u_id = database.find_ID(u_mail)
                        if id_status:
                            database.delete(u_id)
                            status, msg = database.reformat_id()
                            if status:
                                return {'status': True, 'data': '重新排序成功'}
                            else:
                                return {'status': True, 'data': msg}
                            return {'status': True, 'data': '删除成功'}
                        else:
                            return {'status': False, 'data': '服务器错误'}
                    else:
                        return {'status': False, 'data': '密码错误'}
                else:
                    return {'status': False, 'data': '服务器错误'}
            else:
                {'status': False, 'data': '邮箱不存在'}
        else:
            return errors.recaptcha_verify_failed
    else:
        return errors.recaptcha_not_found
Exemplo n.º 2
0
def login():

    print(request.form)

    if request.method == "POST":

        email = request.form["email"]
        password = request.form["password"]
        rememberdetails = "rememberdetails" in request.form

        uid = database.storageSystem.email_to_id(email)

        print("UID: " + uid)

        if uid == None:
            print("Invalid email " + email)
            return generic_error("Invalid email",
                                 "The email address " + email + " isn't valid")
        elif database.check_password(uid, password, rememberdetails):
            return generic_error("Success", "Login success")
        else:
            return generic_error("Invalid password",
                                 "The login credentials are incorrect")

    return render_template("login.html")
Exemplo n.º 3
0
def update():
    if 'g-recaptcha-response' in request.form:
        g_recaptcha_response = request.form['g-recaptcha-response']
        if recaptcha.verify(g_recaptcha_response):
            u_name = request.form['name']
            u_mail = request.form['mail']
            u_password = request.form['password']
            origin_mail = request.form['originMail']
            origin_password = request.form['originPassword']
            has_new_password = False if u_password == '' else True
            # 过滤异常请求,分为更改了密码和未更改密码
            if has_new_password:  # 更改了密码
                u_repeat_password = request.form['repeat-password']
                password = u_password if u_password == u_repeat_password else False
                if not password:
                    return redirect(f'/updateInfo.html?msg=输入的密码不相同', 302)
                if database.is_exist(origin_mail):
                    d_status, d_password = database.query_password(origin_mail)
                    if d_status:
                        if not database.check_password(
                                origin_password,
                                base64.b64decode(d_password).decode()):
                            return redirect(f'/updateInfo.html?msg=认证失败', 302)
                        else:
                            u_password = database.encrypt_password(
                                u_password.encode())  # 成功
                    else:
                        return redirect(f'/updateInfo.html?msg=原密码查询失败', 302)
                else:
                    return redirect(f'/updateInfo.html?msg=邮箱不存在', 302)
            else:  # 未更改密码
                qp_status, p_data = database.query_password(origin_mail)
                if qp_status:
                    # 成功
                    u_password = base64.b64decode(p_data).decode()
                else:
                    return redirect(f'/updateInfo.html?msg=原密码查询失败', 302)
            # 执行 update
            u_pubkey = request.form['pubkey']
            u_uuid = database.get_u_uuid(u_mail)
            u_date = database.get_u_date()
            id_status, u_id = database.find_ID(origin_mail)
            if id_status:
                status, msg = database.update(u_uuid, u_name, u_mail,
                                              u_password, u_pubkey, u_date,
                                              u_id)
                if status:
                    return redirect(f'/searchKey.html?mail={u_mail}&msg=更改成功',
                                    302)
                else:
                    return redirect(f'/searchKey.html?mail={u_mail}&msg={msg}',
                                    302)
            else:
                return redirect(f'/updateInfo.html?msg=停止你的黑客行为!', 302)
        else:
            return redirect(f'/updateInfo.html?msg=reCAPTCHA 令牌无效,请尝试刷新页面',
                            302)
    else:
        return redirect(f'/updateInfo.html?msg=reCAPTCHA 令牌未找到,停止你的黑客行为!', 302)
Exemplo n.º 4
0
def login(conn):
    conn.send(b'Enter username: '******'Enter password: '******'You have been successfully signed in\n')
        cabinet(conn, username)
    else:
        conn.send(b'Failed to login, check if the username and password are correct\n')
Exemplo n.º 5
0
def login():
    if request.method == 'POST':

        username = request.form.get('username')
        password = request.form.get('password')

        try:
            pw = check_password(username)
        except TypeError as e:
            print(e)

        if password == pw:
            session['logged_in_user'] = username
            return jsonify('verified')
        else:
            return jsonify('invalid')
    else:
        return render_template('login.html')
Exemplo n.º 6
0
def verifyPassword():
    if 'g-recaptcha-response' in request.args:
        g_recaptcha_response = request.args['g-recaptcha-response']
        if recaptcha.verify(g_recaptcha_response):
            u_mail = request.args['mail']
            u_password = request.args['password']
            if database.is_exist(u_mail):
                d_status, d_password = database.query_password(u_mail)
                if d_status:
                    if database.check_password(
                            u_password,
                            base64.b64decode(d_password).decode()):
                        return {'status': True, 'data': '认证成功'}
                    else:
                        return {'status': False, 'data': '认证失败'}
                else:
                    return {'status': False, 'data': '服务器错误'}
            else:
                return {'status': False, 'data': '邮箱不存在'}
        else:
            return errors.recaptcha_verify_failed
    else:
        return errors.recaptcha_not_found
Exemplo n.º 7
0
def oauth2_login():
    if request.method == 'POST':

        username = request.form.get('username')
        password = request.form.get('password')

        try:
            pw = check_password(username)
        except TypeError as e:
            print(e)

        if password == pw:
            code = base64.b64encode(os.urandom(6)).decode()
            if username == 'foo':
                update_auth_code('foo', code)
            if username == 'peanut':
                update_auth_code('peanut', code)
            uri = config['callback_uri']
            uri += '?code={}'.format(code)
            return jsonify({'uri': uri})
        else:
            return jsonify('invalid')
    else:
        return render_template('oauth2_login.html')
Exemplo n.º 8
0
 def login_pressed(self):
     username = self.username_entry.get()
     password = self.password_entry.get()
     if username == "" or password == "":
         messagebox.showinfo(title="Unsuccessful",
                             message="Please fill all the entries.")
     else:
         connection = database.connect()
         if not database.check_username(connection, username):
             messagebox.showinfo(title="Unsuccessful",
                                 message="User does not exist.")
             self.username_entry.delete(0, END)
             self.password_entry.delete(0, END)
         else:
             value = database.check_password(connection, username, password)
             if value == "False":
                 messagebox.showinfo(title="Unsuccessful",
                                     message="Incorrect password.")
                 self.password_entry.delete(0, END)
             else:
                 self.window.destroy()
                 self.sign_up = False
                 self.create_homepage = True
                 self.table_name = value