Esempio n. 1
0
def index(request):
    redirect_uri = request.build_absolute_uri(
        reverse('authentication:gettoken'))

    mail = request.session.get('mail', None)

    admin = False
    volunteer = False

    if (mail):
        username = mail.split('@')[0]
        user = get_or_none(User, username=username)
        admin = is_admin(user)
        volunteer = is_volunteer(user)

    context = {
        'name': request.session.get('name', None),
        'roll_number': request.session.get('roll_number', None),
        'mail': request.session.get('mail', None),
        'access_token': request.session.get('access_token', None),
        'sign_in_url': get_signin_url(redirect_uri),
        "is_admin": admin,
        "is_volunteer": volunteer
    }

    return render(request, 'index.html', context)
Esempio n. 2
0
def home(request):

    # Redirecting to gettoken view after authenticating
    redirect_uri = request.build_absolute_uri(
        reverse('authentication:gettoken'))

    # Building the sign in url
    sign_in_url = get_signin_url(redirect_uri)
    # print(sign_in_url)
    return redirect(sign_in_url)
Esempio n. 3
0
def home(request):

    # Redirecting to gettoken view after authenticating
    redirect_uri = request.build_absolute_uri(
        reverse('authentication:gettoken'))

    # Building the sig in url
    sign_in_url = get_signin_url(redirect_uri)

    return HttpResponse('<a href="' + sign_in_url +
                        '">Click here to sign in and test outlook OAuth2</a>')
Esempio n. 4
0
def results_login(request):
    if request.method == "GET":
        redirect_uri = request.build_absolute_uri(
            reverse('authentication:gettoken'))
        request.session['save_user'] = True
        request.session['redirect_url'] = 'results'
        already_logged_in = request.session.get('logins', list())
        if (set(ADMINS).issubset(set(already_logged_in))):
            s = time.time()
            try:
                pkl_file = open('results.pkl', 'rb')
                results_dict = pickle.load(pkl_file)
                print('Read Pickle')
            except:
                results_dict = dict()
            return render(request, 'results.html',
                          {'results_dict': results_dict})

        return render(
            request, 'results.html', {
                'already_logged_in': already_logged_in,
                'sign_in_url': get_signin_url(redirect_uri)
            })
Esempio n. 5
0
def home(request):
    redirect_uri = request.build_absolute_uri(
        reverse('authentication:gettoken'))
    sign_in_url = get_signin_url(redirect_uri)
    return HttpResponse('<a href="' + sign_in_url +
                        '">Click here to sign in and test outlook OAuth2</a>')