def create_admin_user(): """Creates an admin user""" email = core.app.config.get('ADMIN_USER', '*****@*****.**') pwd = core.app.config.get('ADMIN_PASSWORD', 'secret') user = User.by_email(email) if user is not None: print('Admin user already there.') return else: user = User(email=email, password=pwd) user.save() print('Admin user created.')
def login(): print('login called') #print(url_for('api.add', _external=True)) form = LoginForm() pprint(form) if form.validate_on_submit(): user = User.by_email(form.email.data) if user is not None and user.password == form.password.data: login_user(user, remember=True) flash("Logged in successfully.") print("Logged in successfully.") if request.args.get('jsonify', "true") == "false": rsp = redirect(url_for('ui.home')) else: rsp = make_response(jsonify(success=True, output="Successfully logged in.")) return rsp else: if request.args.get('jsonify', "true") == "false": return redirect(url_for('ui.login_view')) else: return jsonify(success=False, output="Bad password.", callback="/feeds/login")