Beispiel #1
0
def login_attempt(token, profile): # Google login was successful, so we attempt to log in to pictur now
    google_email = profile['email']
    data = sql_controller.get_user_by_email(google_email)
    if data:
        user = User()
        user.uid = data['uid']
        user.active = True
        success = flask_login.login_user(user)
        #return str(success) + ':' + user.to_string()
        return redirect(url_for('index')) # Login successful redirect to main page
    # Email not registered, ask if they want to register
    uid = sql_controller.insert_user("", google_email)
    user = User()
    user.uid = uid
    user.active = True
    flask_login.login_user(user)
    return redirect(url_for('signup')) 
Beispiel #2
0
def search_user():
    page_context = {}
    user = flask_login.current_user
    if user.is_anonymous():
        user = User()
    else:
        if len(user.username.strip()) == 0: return redirect(url_for('signup'))
    if request.method == 'POST' and UPLOADS_FOLDER is not '':
        return process_upload(request)
    if not user.is_anonymous():
        page_context['username'] = user.username
    page_context['id_to_path'] = id_to_path		
    page_context['google_url'] = google_login.authorization_url() 
    page_context['uid'] = user.uid
	
    email = request.args.get('email')
    if email != None and email != '':
        s_user = sql_controller.get_user_by_email(email)
        if s_user != None and s_user != '':
            return redirect(url_for('profile', profileid = s_user.uid))
    posts = sql_controller.tag_search(email, 9)
    return render_template('front.html', posts=posts, page_context = page_context).format(google_login.authorization_url())