So I'm creating a simple website in flask that allows two types of users. Admin and regular users. I have a class called "User" which has an attribute "isUser". I then have a route call "addMovie" which takes in a parameter "isUser" to check to see if the current user has the rights to add a movie. How do I check that? As of right now, I user that has that attribute set to "Yes" can still add a movie.
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.String(120))
last_name = db.Column(db.String(120))
email = db.Column(db.String(180), unique=True)
password = db.Column(db.String(255))
isUser = db.Column(db.String(10))
active = db.Column(db.Boolean())
confirmed_at = db.Column(db.DateTime())
roles = db.relationship('Role', secondary=roles_users,backref=db.backref('users', lazy='dynamic'))
@app.route('/addMovie/<isUser>', methods=['GET', 'POST'])
@login_required
def addMovie(isUser):
error = None
if(isUser == "Yes"):
error = "You must have Admin Privaledges to add a Movie/TV Show"
return redirect(url_for('index'))
else:
return render_template('addMovie.html', error=error)