Exemplo n.º 1
0
def login():
    if request.method == 'POST' and 'user_id' not in session:
        username = request.form['username']
        encrypted_username = Encryption.encrypt(ENCRYPTION_KEY,
                                                request.form['username'])
        password = request.form['password']
        users = User.query.filter_by(
            encrypted_username=encrypted_username).all()
        for user in users:
            if username == user.username and sha256_crypt.verify(
                    password, user.password):
                session['user_id'] = user.id
                flash('Hello  ' + user.name + '!', 'success')
                return redirect(url_for('dashboard_blueprint.user_dashboard'))
        flash('Account not found. Try logging in again.', 'danger')
        return render_template('content/login.html')
    session.pop('user_id', None)
    return render_template('content/login.html')
Exemplo n.º 2
0
 def username(self, value):
     self.encrypted_username = Encryption.encrypt(ENCRYPTION_KEY, value)
Exemplo n.º 3
0
 def likes_hobbies(self, value):
     self.encrypted_likes_hobbies = Encryption.encrypt(
         ENCRYPTION_KEY, value)
Exemplo n.º 4
0
 def email(self, value):
     self.encrypted_email = Encryption.encrypt(ENCRYPTION_KEY, value)
Exemplo n.º 5
0
 def address(self, value):
     self.encrypted_address = Encryption.encrypt(ENCRYPTION_KEY, value)
Exemplo n.º 6
0
 def username(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_username)
Exemplo n.º 7
0
 def likes_hobbies(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_likes_hobbies)
Exemplo n.º 8
0
 def email(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_email)
Exemplo n.º 9
0
 def address(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_address)
Exemplo n.º 10
0
 def password(self, value):
     self.encrypted_password = Encryption.encrypt(ENCRYPTION_KEY, value)
Exemplo n.º 11
0
 def social_media(self, value):
     self.encrypted_social_media = Encryption.encrypt(ENCRYPTION_KEY, value)
Exemplo n.º 12
0
 def password(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_password)
Exemplo n.º 13
0
 def social_media(self):
     return Encryption.decrypt(ENCRYPTION_KEY, self.encrypted_social_media)