Commit 3e536c8a authored by Jon Yu's avatar Jon Yu
Browse files

Replace login links with OIDC paths

parent c4f8cdbb
from django.contrib import admin
from django.urls import path, include
from .views import login, logout
urlpatterns = [
path('login/', login, name='login'),
path('logout/', logout, name='logout'),
path('', include('um_template_ui.urls')),
path('', include('oidc_auth.urls'))
from django.contrib.auth import logout as auth_logout
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.shortcuts import render
def login(request):
return render(request, 'um_template_ui/index.html')
def logout(request):
return HttpResponseRedirect(reverse('home'))
# Create your views here.
{% load static %}
<!doctype html>
<html lang="en">
<html lang="en">
{% block head %}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
......@@ -13,9 +13,9 @@
{% block styles %}{% endblock %}
<title>University of Michigan {% block title %}{% endblock %}</title>
{% endblock %}
<nav class="navbar navbar-dark navbar-expand-md fixed-top">
<a class="navbar-brand" href="{% url 'um_template_ui:home' %}"><img class="img-fluid my-1 py-1" src="{% static 'images/its-logo.png' %}" /></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarLinks" aria-controls="navbarLinks" aria-expanded="false" aria-label="Toggle navigation">
......@@ -23,23 +23,21 @@
<div class="collapse navbar-collapse" id="navbarLinks">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{% url 'um_template_ui:home' %}">Home</a>
<div class="navbar-nav ml-auto">
{% if request.user.is_authenticated %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="userMenu" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ request.user.username }}
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userMenu">
<a href="{% url 'logout' %}" class="dropdown-item">Logout</a>
<div class="dropdown-menu" aria-labelledby="userMenu">
<form action="{% url 'oidc_logout' %}" method="post">
{% csrf_token %}
<input type="submit" value="logout" style="background-color: white" class="dropdown-item">
{% else %}
<a href="{% url 'login' %}?next={{ request.get_full_path }}" class="nav-link">Login</a>
<a href="{% url 'oidc_authentication_init' %}" class="nav-link">Login</a>
{% endif %}
......@@ -50,12 +48,11 @@
{% block content %}
{% endblock %}
</main><!-- /.container -->
<script src="" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
{% block scripts %}{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment