Skip to content
Snippets Groups Projects
Commit 2b5130e4 authored by Stein Elgethun's avatar Stein Elgethun
Browse files

Add button for sending testmail in frontend

Issue: GREG-66
parent 61c2a8b6
No related branches found
No related tags found
1 merge request!98Greg 66 mail queue
Pipeline #96148 passed
......@@ -82,6 +82,19 @@ export const Debug = () => {
})
}
const testMail = () => {
fetch('/api/ui/v1/testmail/', {
credentials: 'same-origin',
})
.then((data) => {
console.log(data)
})
.catch((err) => {
console.log(err)
})
}
const whoami = () => {
fetch('/api/ui/v1/whoami/', {
headers: {
......@@ -151,6 +164,9 @@ export const Debug = () => {
<Button type="button" onClick={() => logout()}>
LOGOUT
</Button>
<Button type="button" onClick={() => testMail()}>
SEND TEST MAIL
</Button>
</Stack>
<Box sx={{ maxWidth: '30rem' }}>
<Table>
......
......@@ -17,6 +17,7 @@ urlpatterns: List[URLResolver] = [
path("api/ui/v1/logout/", views.logout_view, name="api-logout"),
path("api/ui/v1/login/", views.login_view, name="api-login"),
path("api/ui/v1/session/", views.SessionView.as_view(), name="api-session"),
path("api/ui/v1/testmail/", views.send_test_email, name="api-testmail"),
path("api/ui/v1/whoami/", views.WhoAmIView.as_view(), name="api-whoami"),
path("api/ui/v1/userinfo/", UserInfoView.as_view()), # type: ignore
path("api/ui/v1/ous/", OusView.as_view()),
......
......@@ -8,6 +8,7 @@ from rest_framework.views import APIView
from greg.models import Role, Sponsor
from greg.permissions import IsSponsor
from gregui import mailutils
from gregui.models import GregUserProfile
......@@ -37,6 +38,11 @@ def login_view(request):
return redirect("/api/ui/v1/whoami/")
def send_test_email(request):
mailutils.send_registration_mail("test@example.no", "Foo Bar")
return JsonResponse({"detail": "Created task to send test mail."})
class SessionView(APIView):
authentication_classes = [SessionAuthentication, BasicAuthentication]
permission_classes = [IsAuthenticated]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment