A clean, Markdown-based publishing platform made for writers. Write together, and build a community. https://writefreely.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

175 lines
5.8 KiB

  1. {{define "head"}}<title>Log in &mdash; {{.SiteName}}</title>
  2. <meta name="description" content="Log in to {{.SiteName}}.">
  3. <meta itemprop="description" content="Log in to {{.SiteName}}.">
  4. <style>input{margin-bottom:0.5em;}</style>
  5. <style type="text/css">
  6. h2 {
  7. font-weight: normal;
  8. }
  9. #pricing.content-container div.form-container #payment-form {
  10. display: block !important;
  11. }
  12. #pricing #signup-form table {
  13. max-width: inherit !important;
  14. width: 100%;
  15. }
  16. #pricing #payment-form table {
  17. margin-top: 0 !important;
  18. max-width: inherit !important;
  19. width: 100%;
  20. }
  21. tr.subscription {
  22. border-spacing: 0;
  23. }
  24. #pricing.content-container tr.subscription button {
  25. margin-top: 0 !important;
  26. margin-bottom: 0 !important;
  27. width: 100%;
  28. }
  29. #pricing tr.subscription td {
  30. padding: 0 0.5em;
  31. }
  32. #pricing table.billing > tbody > tr > td:first-child {
  33. vertical-align: middle !important;
  34. }
  35. .billing-section {
  36. display: none;
  37. }
  38. .billing-section.bill-me {
  39. display: table-row;
  40. }
  41. #btn-create {
  42. color: white !important;
  43. }
  44. #total-price {
  45. padding-left: 0.5em;
  46. }
  47. #alias-site.demo {
  48. color: #999;
  49. }
  50. #alias-site {
  51. text-align: left;
  52. margin: 0.5em 0;
  53. }
  54. form dd {
  55. margin: 0;
  56. }
  57. </style>
  58. {{end}}
  59. {{define "content"}}
  60. <div id="pricing" class="tight content-container">
  61. <h1>Log in to {{.SiteName}}</h1>
  62. {{if .Flashes}}<ul class="errors">
  63. {{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
  64. </ul>{{end}}
  65. <div id="billing">
  66. <form action="/oauth/signup" method="post" style="text-align: center;margin-top:1em;" onsubmit="return disableSubmit()">
  67. <input type="hidden" name="access_token" value="{{ .AccessToken }}" />
  68. <input type="hidden" name="token_username" value="{{ .TokenUsername }}" />
  69. <input type="hidden" name="token_alias" value="{{ .TokenAlias }}" />
  70. <input type="hidden" name="token_email" value="{{ .TokenEmail }}" />
  71. <input type="hidden" name="token_remote_user" value="{{ .TokenRemoteUser }}" />
  72. <input type="hidden" name="provider" value="{{ .Provider }}" />
  73. <input type="hidden" name="client_id" value="{{ .ClientID }}" />
  74. <input type="hidden" name="signature" value="{{ .TokenHash }}" />
  75. <dl class="billing">
  76. <label>
  77. <dt>Display Name</dt>
  78. <dd>
  79. <input type="text" style="width: 100%; box-sizing: border-box;" name="alias" placeholder="Name"{{ if .Alias }} value="{{.Alias}}"{{ end }} />
  80. </dd>
  81. </label>
  82. <label>
  83. <dt>Username</dt>
  84. <dd>
  85. <input type="text" id="username" name="username" style="width: 100%; box-sizing: border-box;" placeholder="Username" value="{{.LoginUsername}}" /><br />
  86. {{if .Federation}}<p id="alias-site" class="demo">@<strong>your-username</strong>@{{.FriendlyHost}}</p>{{else}}<p id="alias-site" class="demo">{{.FriendlyHost}}/<strong>your-username</strong></p>{{end}}
  87. </dd>
  88. </label>
  89. <label>
  90. <dt>Email</dt>
  91. <dd>
  92. <input type="text" name="email" style="width: 100%; box-sizing: border-box;" placeholder="Email"{{ if .Email }} value="{{.Email}}"{{ end }} />
  93. </dd>
  94. </label>
  95. <dt>
  96. <input type="submit" id="btn-login" value="Login" />
  97. </dt>
  98. </dl>
  99. </form>
  100. </div>
  101. <script type="text/javascript" src="/js/h.js"></script>
  102. <script type="text/javascript">
  103. // Copied from signup.tmpl
  104. // NOTE: this element is named "alias" on signup.tmpl and "username" here
  105. var $alias = H.getEl('username');
  106. function disableSubmit() {
  107. // Validate input
  108. if (!aliasOK) {
  109. var $a = $alias;
  110. $a.el.className = 'error';
  111. $a.el.focus();
  112. $a.el.scrollIntoView();
  113. return false;
  114. }
  115. var $btn = document.getElementById("btn-login");
  116. $btn.value = "Logging in...";
  117. $btn.disabled = true;
  118. return true;
  119. }
  120. // Copied from signup.tmpl
  121. var $aliasSite = document.getElementById('alias-site');
  122. var aliasOK = true;
  123. var typingTimer;
  124. var doneTypingInterval = 750;
  125. var doneTyping = function() {
  126. // Check on username
  127. var alias = $alias.el.value;
  128. if (alias != "") {
  129. var params = {
  130. username: alias
  131. };
  132. var http = new XMLHttpRequest();
  133. http.open("POST", '/api/alias', true);
  134. // Send the proper header information along with the request
  135. http.setRequestHeader("Content-type", "application/json");
  136. http.onreadystatechange = function() {
  137. if (http.readyState == 4) {
  138. data = JSON.parse(http.responseText);
  139. if (http.status == 200) {
  140. aliasOK = true;
  141. $alias.removeClass('error');
  142. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)demo(?!\S)/g, '');
  143. $aliasSite.className = $aliasSite.className.replace(/(?:^|\s)error(?!\S)/g, '');
  144. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>' + data.data + '</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>' + data.data + '</strong>/{{ end }}';
  145. } else {
  146. aliasOK = false;
  147. $alias.setClass('error');
  148. $aliasSite.className = 'error';
  149. $aliasSite.textContent = data.error_msg;
  150. }
  151. }
  152. }
  153. http.send(JSON.stringify(params));
  154. } else {
  155. $aliasSite.className += ' demo';
  156. $aliasSite.innerHTML = '{{ if .Federation }}@<strong>your-username</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>your-username</strong>/{{ end }}';
  157. }
  158. };
  159. $alias.on('keyup input', function() {
  160. clearTimeout(typingTimer);
  161. typingTimer = setTimeout(doneTyping, doneTypingInterval);
  162. });
  163. doneTyping();
  164. </script>
  165. {{end}}