def create_account(self,bank_ID):
     virtID = db.get_virtual_ID()
     account_num = db.get_account()
     self.full_name = self.first_name, self.last_name
     self.account_info = db.get_accounts(virtID, account_num, self.full_name, self.social, self.address,self.balance,bank_ID)
     print("Account saved.")
     return self.account_info
示例#2
0
文件: app.py 项目: gky360/study_ctf
def index():
    t = time.perf_counter()

    if request.method == "GET":
        return render_template("index.html",
                               message="Please login.",
                               sec="{:.7f}".format(time.perf_counter() - t))

    if request.method == "POST":
        name = request.form["name"]
        password = request.form["password"]

        exists, account = db.get_account(name)

        if not exists:
            return render_template("index.html",
                                   message="Login failed, try again.",
                                   sec="{:.7f}".format(time.perf_counter() -
                                                       t))

        # auth.calc_password_hash(salt, password) adds salt and performs stretching so many times.
        # You know, it's really secure... isn't it? :-)
        hashed_password = auth.calc_password_hash(app.SALT, password)
        if hashed_password != account.password:
            return render_template("index.html",
                                   message="Login failed, try again.",
                                   sec="{:.7f}".format(time.perf_counter() -
                                                       t))

        session["name"] = name
        return render_template("dashboard.html",
                               sec="{:.7f}".format(time.perf_counter() - t))
示例#3
0
def load_account():
    user_id = flask.session.get('user_id')
    account = None
    if user_id:
        account = db.get_account(user_id)
    flask.g.account = account or {}
    flask.g.user_id = user_id
示例#4
0
def login_complete(resp):
    if resp is None:
        return flask.redirect('/')
    user_id = resp['user_id']
    account = db.get_account(user_id)
    if not account:
        account = resp
        account['created_at'] = time.time()
    db.put_account(user_id, account)
    flask.session['user_id'] = user_id
    sid = flask.session.pop('temp_session_id', default=None)
    if sid:
        ids = db.pop_temp_session(sid)
        db.add_favorites(user_id, ids)
        flask.flash(u'환영합니다! 선택하신 작품 %d개가 관심 체크 됐습니다.' % len(ids))
    return flask.redirect('/')