def inject_stuff(): action = DB() if session.get('id'): user_id = session['id'] folders = action.getFoldersByUserId(session['id']) tagCounts = {} tagCounts['starred'] = action.getStarredImageCountByUserId(user_id) tagCounts['toedit'] = action.getToEditImageCountByUserId(user_id) tagCounts['edited'] = action.getEditedImageCountByUserId(user_id) tagCounts['public'] = action.getPublicImageCountByUserId(user_id) tagCounts['deleted'] = action.getDeletedImageCountByUserId(user_id) return { 'now': datetime.utcnow(), 'tagCounts': tagCounts, 'folders': folders } return {'now': datetime.utcnow(), 'tagCounts': 0}
def signinAction(email=None, password=None): if request.method == 'POST' or (email and password): action = DB() email = request.form['inputEmail'] password = request.form['inputPassword'] if action.validateCreds(email, password): session['active'] = True userInfo = action.getUserInfoByEmail(email) user = User(userInfo[0], userInfo[1], userInfo[2]) session['first'] = user.first session['last'] = user.last session['email'] = user.email # session['folder'] = user.folder user_id = action.getUserIdByEmail(email) session['folders'] = action.getFoldersByUserId(user_id) session['id'] = user_id action.recordLogin(user_id) else: flash('Email and password don\'t match', 'danger') return render_template('core/signin.html') return redirect('/')