|
1 | | -{# Auth redirect template for Dev Toolbar. Returned after successfully logging in to a requested organization. #} |
| 1 | +{% extends "sentry/bases/auth.html" %} |
| 2 | + |
2 | 3 | {% load sentry_assets %} |
3 | | -<!DOCTYPE html> |
4 | | -<html lang="en"> |
5 | | - <head> |
6 | | - <title>Sentry - Login Success</title> |
7 | | - <link rel="icon" type="image/png" href="{% absolute_asset_url "sentry" "images/favicon.png" %}"> |
8 | | - </head> |
9 | | - <body> |
10 | | - <div> |
11 | | - <p>You are logged in!</p> |
12 | | - <p>This window will automatically close after {{ delay_sec }} seconds. If not then check the console for errors.</p> |
13 | | - <button type="button" id="close-popup">Close Popup</button> |
14 | | - </div> |
15 | | - |
16 | | - {% script %} |
17 | | - <script> |
18 | | - (function() { |
19 | | - const orgSlug = '{{ organization_slug|escape }}'; |
20 | | - const delay = {{ delay_ms|escapejs }}; |
21 | | - const cookie = '{{ cookie|escapejs }}'; |
22 | | - const token = '{{ token|escapejs }}'; |
23 | | - |
24 | | - if (window.location.origin === 'https://sentry.io') { |
25 | | - // User was already logged in and didn't get a redirect to the |
26 | | - // subdomained origin. Do that redirect now. |
27 | | - window.location.replace(`https://${orgSlug}.sentry.io${window.location.pathname}${window.location.search}`); |
28 | | - return; |
29 | | - } |
| 4 | +{% load i18n %} |
| 5 | + |
| 6 | +{% block title %}{% trans "Sentry Toolbar - Login Success" %} | {{ block.super }}{% endblock %} |
| 7 | + |
| 8 | +{% block auth_main %} |
| 9 | + <div> |
| 10 | + <h4>You're logged in!</h4> |
| 11 | + {% if delay_sec %} |
| 12 | + <p>This window will automatically close after {{ delay_sec }} seconds.</p> |
| 13 | + <p>If not then check the console for errors.</p> |
| 14 | + {% endif %} |
| 15 | + <button type="button" id="close-popup" class="btn btn-primary">Close Popup</button> |
| 16 | + </div> |
| 17 | +{% endblock %} |
| 18 | + |
| 19 | +{% block scripts_bottom %} |
| 20 | + {{ block.super }} |
| 21 | + {% script %} |
| 22 | + <script> |
| 23 | + (function() { |
| 24 | + const orgSlug = '{{ organization_slug|escape }}'; |
| 25 | + const delay = {{ delay_ms|escapejs }}; |
| 26 | + const cookie = '{{ cookie|escapejs }}'; |
| 27 | + const token = '{{ token|escapejs }}'; |
| 28 | + |
| 29 | + if (window.location.origin === 'https://sentry.io') { |
| 30 | + // User was already logged in and didn't get a redirect to the |
| 31 | + // subdomained origin. Do that redirect now. |
| 32 | + window.location.replace(`https://${orgSlug}.sentry.io${window.location.pathname}${window.location.search}`); |
| 33 | + return; |
| 34 | + } |
| 35 | + |
| 36 | + document.getElementById('close-popup').addEventListener('click', () => { |
| 37 | + window.close(); |
| 38 | + }); |
| 39 | + |
| 40 | + if (window.opener) { |
| 41 | + window.opener.postMessage({ |
| 42 | + source: 'sentry-toolbar', |
| 43 | + message: 'did-login', |
| 44 | + cookie, |
| 45 | + token, |
| 46 | + }, window.location.origin); |
30 | 47 |
|
31 | | - document.getElementById('close-popup').addEventListener('click', () => { |
32 | | - window.close(); |
33 | | - }); |
34 | | - |
35 | | - if (window.opener) { |
36 | | - window.opener.postMessage({ |
37 | | - source: 'sentry-toolbar', |
38 | | - message: 'did-login', |
39 | | - cookie, |
40 | | - token, |
41 | | - }, window.location.origin); |
42 | | - |
43 | | - if (delay && typeof delay === 'number') { |
44 | | - setTimeout(() => { |
45 | | - window.close(); |
46 | | - }, delay); |
47 | | - } |
| 48 | + if (delay && typeof delay === 'number') { |
| 49 | + setTimeout(() => { |
| 50 | + window.close(); |
| 51 | + }, delay); |
48 | 52 | } |
49 | | - })(); |
50 | | - </script> |
51 | | - {% endscript %} |
52 | | - |
53 | | -{% comment %} |
54 | | -No need to close `body`. If we do then middleware will inject some extra markup |
55 | | -we don't need. Browsers can figure out when it missing and deal with it. |
56 | | -{% endcomment %} |
| 53 | + } |
| 54 | + })(); |
| 55 | + </script> |
| 56 | + {% endscript %} |
| 57 | +{% endblock %} |
0 commit comments