flask-security

flask_sqlalchemy object does not have attribute add when using flask_security

别说谁变了你拦得住时间么 提交于 2020-05-28 07:44:06
问题 I am trying to add some roles/users with flask_security but run into this issue when I try to create users with the SQLAlchemySessionUserDatastore . So I first start by creating user_datastore like the guide db = SQLAlchemy(app) user_datastore = SQLAlchemySessionUserDatastore(db, User, Role) security = Security(app, user_datastore) user_datastore.create_user(email='test', password='passowrd') this is where I deviate from the guide and try to just create a test user. Looks like the db =

Proper way for user authentication with angularjs and flask

时光总嘲笑我的痴心妄想 提交于 2020-01-30 14:17:32
问题 I'm currently working my way through Web development with flask. I want to build a webapp with flask as backend and angular.js at the frontend. The Json part is straight forward, and my first steps work out well. But now I got stuck with User Authentication. I read a lot but found out, that WTFForms works not as well with angular (without the CSFR Token), so i can not use something like flask-security. What is a proper way or maybe the best pratice for implementing User authentication with

flask security separating access data on flask admin

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-16 18:18:08
问题 i have an aplication homestay reservation built with flask.. every homestay have an user login, this login built with flask-security and every owner of the homestay have role User . and every user can input their homestay data with flask-admin. but unfortunately if a user input their data, the others user which have role User can seing the data have input too.. so.. my question how to separate the data if a user have the same role..? user A can just see his data, and user B so too.. this is

flask-security - admin create user, force user to choose password

本小妞迷上赌 提交于 2020-01-15 15:08:32
问题 Using flask-security, I want my flow to be similar to as follows: admin creates user admin sends user notification email they've been created user uses link in notification email to set password I tried using the forgot_password view from the admin account for step 2, but https://github.com/jwag956/flask-security/blob/743be9c979b558b4ecfb177dc8117c0bf55e38ed/flask_security/views.py#L464 requires anonymous user and therefore redirects. I see https://stackoverflow.com/a/31228170/799921 but it's

Admin(only) registration of users, Flask-Security

家住魔仙堡 提交于 2020-01-13 13:31:13
问题 I'm currently building a login for a webapp using Flask-Security (which includes Flask-WTForms, Flask-SQLalchemy and Flask-Login). I've been able to fairly painlessly set up the majority of my login flow, including forgotten password; however I want to make it so that the only way users can be registered is through a page only accessible to the admins. I've managed to configure Roles (Admin, User) and set up the following view: @app.route('/adminregister') @roles_accepted('admin') def

Flask + Flask-Security + Babel not working

浪子不回头ぞ 提交于 2020-01-05 05:29:47
问题 I have setup with Flask + Babel + Flask Security. Created all translation like this: root main.py translations ru LC_MESSAGES messages.mo messages.po In main.py there is part to setup language which executes: @babel.localeselector def get_locale(): user = getattr(g, 'user', None) if user is not None: print("User locale {}".format(user.locale)) return user.locale # I put here constant to test return 'ru' But http://localhost/login stayed untranslated. Can you please advice where else to dig?

Not getting signal from Flask-Security

你离开我真会死。 提交于 2020-01-05 04:42:44
问题 I want to receive the user_registered signal from Flask-Security and have to set up like so: from flask.ext.security.signals import user_registered @user_registered.connect_via(app) def user_registered_sighandler(sender, **extra): sender.logger.debug("logger-user_registered_sighandler:", extra) print "print-user_registered_sighandler:", extra But my signal handler is not being called when a new user is registered. I've set up a Flask (not Flask-Security) signal similar to above that does work

Unhashable Type error when modifying SqlAlchemy Models

元气小坏坏 提交于 2020-01-04 17:33:32
问题 I am using the most basic flask app practically copied from documentations, and am receiving an extremely annoying error. I've been able to trace it down but don't know how to solve it. I know the problem arises when implementing flask-security, but the error comes from inside sqlalchemy. Any advice? from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy import logging app = Flask(__name__) app.config['DEBUG'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' #

Unhashable Type error when modifying SqlAlchemy Models

牧云@^-^@ 提交于 2020-01-04 17:31:41
问题 I am using the most basic flask app practically copied from documentations, and am receiving an extremely annoying error. I've been able to trace it down but don't know how to solve it. I know the problem arises when implementing flask-security, but the error comes from inside sqlalchemy. Any advice? from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy import logging app = Flask(__name__) app.config['DEBUG'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:' #

Flask-security create role,user and linking user_id to role_id

这一生的挚爱 提交于 2020-01-04 02:54:59
问题 I using Flask-Security with SQLAlchemy When want to add user or role def addrole(): form=addroll() createRole=user_datastore.create_role(name=form.role.data,description=form.description.data) db.session.add(createRole) db.session.commit() in mysql table add one record belong my creation and two or tree blank record same think happen when i want to create user To associate a user with a role, I have the following : @app.route('/addR', methods=['GET', 'POST']) @login_required def addR(): email1