Пример #1
0
 def settings():
     if request.method == 'POST':
         password = request.form['password']
         if password != "":
             password = utils.hash_password(password)
         email = request.form['email']
         utils.change_user(password=password, mail=email)
         return json.dumps({'status': 'Saved'})
     user = utils.get_user()
     return render_template('settings.html', user=user)
Пример #2
0
 def signup():
     if not session.get('logged_in'):
         form = LoginForm(request.form)
         if request.method == 'POST':
             username = request.form['username'].lower()
             password = utils.hash_password(request.form['password'])
             email = request.form['email']
             if form.validate():
                 if utils.username_taken(username):
                     flash("Username taken")
                     return json.dumps({'status': 'Username taken'})
                 if utils.mail_taken(email):
                     flash("Email taken")
                     return json.dumps({'status': 'Email taken'})
                 if utils.add_user(username, password, email, mail_sender):
                     session['logged_in'] = True
                     session['username'] = username
                     flash("Signup successful")
                     return json.dumps({'status': 'Signup successful'})
                 flash("Signup failed")
                 return json.dumps({'status': 'Signup failed'})
             flash('All fields required')
             return json.dumps({'status': 'All fields required'})
     return redirect(url_for('unconfirmed'))