2020-04-22 15:27:19 +02:00
{{define "head"}}<title>Finish Creating Account — {{.SiteName}}</title>
2020-01-03 19:50:21 +01:00
<style>input{margin-bottom:0.5em;}</style>
2020-01-08 04:13:29 +01:00
<style type="text/css">
h2 {
font-weight: normal;
}
#pricing . content - container div . form - container # payment-form {
display: block !important;
}
#pricing # signup-form table {
max-width: inherit !important;
width: 100%;
}
#pricing # payment-form table {
margin-top: 0 !important;
max-width: inherit !important;
width: 100%;
}
tr.subscription {
border-spacing: 0;
}
#pricing . content - container tr . subscription button {
margin-top: 0 !important;
margin-bottom: 0 !important;
width: 100%;
}
#pricing tr . subscription td {
padding: 0 0.5em;
}
#pricing table . billing > tbody > tr > td : first - child {
vertical-align: middle !important;
}
.billing-section {
display: none;
}
.billing-section.bill-me {
display: table-row;
}
#btn - create {
color: white !important;
}
#total - price {
padding-left: 0.5em;
}
#alias - site . demo {
color: #999;
}
#alias - site {
text-align: left;
margin: 0.5em 0;
}
form dd {
margin: 0;
}
</style>
2020-01-02 21:33:39 +01:00
{{end}}
{{define "content"}}
2020-01-08 04:13:29 +01:00
<div id="pricing" class="tight content-container">
2020-04-22 15:27:19 +02:00
<h1>Finish creating account</h1>
2020-01-03 19:50:21 +01:00
{{if .Flashes}}<ul class="errors">
{{range .Flashes}}<li class="urgent">{{.}}</li>{{end}}
</ul>{{end}}
2020-01-08 04:13:29 +01:00
<div id="billing">
2020-01-16 19:13:33 +01:00
<form action="/oauth/signup" method="post" style="text-align: center;margin-top:1em;" onsubmit="return disableSubmit()">
2020-01-08 04:13:29 +01:00
<input type="hidden" name="access_token" value="{{ .AccessToken }}" />
<input type="hidden" name="token_username" value="{{ .TokenUsername }}" />
<input type="hidden" name="token_alias" value="{{ .TokenAlias }}" />
<input type="hidden" name="token_email" value="{{ .TokenEmail }}" />
<input type="hidden" name="token_remote_user" value="{{ .TokenRemoteUser }}" />
<input type="hidden" name="provider" value="{{ .Provider }}" />
<input type="hidden" name="client_id" value="{{ .ClientID }}" />
<input type="hidden" name="signature" value="{{ .TokenHash }}" />
2020-04-21 00:18:23 +02:00
{{if .InviteCode}}<input type="hidden" name="invite_code" value="{{ .InviteCode }}" />{{end}}
2020-01-03 19:50:21 +01:00
2020-01-08 04:13:29 +01:00
<dl class="billing">
<label>
2020-01-16 19:58:14 +01:00
<dt>Display Name</dt>
2020-01-08 04:13:29 +01:00
<dd>
2020-01-16 19:58:14 +01:00
<input type="text" style="width: 100%; box-sizing: border-box;" name="alias" placeholder="Name"{{ if .Alias }} value="{{.Alias}}"{{ end }} />
2020-01-08 04:13:29 +01:00
</dd>
</label>
<label>
<dt>Username</dt>
<dd>
2020-01-16 19:37:44 +01:00
<input type="text" id="username" name="username" style="width: 100%; box-sizing: border-box;" placeholder="Username" value="{{.LoginUsername}}" /><br />
2020-01-08 04:13:29 +01:00
{{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}}
</dd>
</label>
<label>
<dt>Email</dt>
<dd>
<input type="text" name="email" style="width: 100%; box-sizing: border-box;" placeholder="Email"{{ if .Email }} value="{{.Email}}"{{ end }} />
</dd>
</label>
<dt>
2020-04-22 15:27:19 +02:00
<input type="submit" id="btn-login" value="Next" />
2020-01-08 04:13:29 +01:00
</dt>
</dl>
</form>
</div>
2020-01-02 21:33:39 +01:00
2020-01-16 19:13:33 +01:00
<script type="text/javascript" src="/js/h.js"></script>
2020-01-02 21:33:39 +01:00
<script type="text/javascript">
2020-01-16 19:13:33 +01:00
// Copied from signup.tmpl
// NOTE: this element is named "alias" on signup.tmpl and "username" here
var $ alias = H.getEl('username');
2020-01-03 19:50:21 +01:00
function disableSubmit() {
2020-01-16 19:13:33 +01:00
// Validate input
if (!aliasOK) {
var $a = $ alias ;
$ a . el . className = 'error';
$ a . el . focus ();
$ a . el . scrollIntoView ();
return false;
}
2020-01-03 19:50:21 +01:00
var $ btn = document.getElementById("btn-login");
$ btn . value = "Logging in...";
2020-01-02 21:33:39 +01:00
$ btn . disabled = true;
2020-01-16 19:13:33 +01:00
return true;
2020-01-02 21:33:39 +01:00
}
2020-01-16 19:13:33 +01:00
// Copied from signup.tmpl
var $ aliasSite = document.getElementById('alias-site');
var aliasOK = true;
var typingTimer;
var doneTypingInterval = 750;
2020-04-22 15:17:25 +02:00
var doneTyping = function(genID) {
2020-01-16 19:13:33 +01:00
// Check on username
var alias = $ alias . el . value ;
if (alias != "") {
var params = {
username: alias
};
var http = new XMLHttpRequest();
http.open("POST", '/api/alias', true);
// Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/json");
http.onreadystatechange = function() {
if (http.readyState == 4) {
data = JSON.parse(http.responseText);
if (http.status == 200) {
aliasOK = true;
$ alias . removeClass ('error');
$ aliasSite . className = $ aliasSite . className . replace (/(?:^|\s)demo(?!\S)/g, '');
$ aliasSite . className = $ aliasSite . className . replace (/(?:^|\s)error(?!\S)/g, '');
$ aliasSite . innerHTML = '{{ if .Federation }}@<strong>' + data.data + '</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>' + data.data + '</strong>/{{ end }}';
} else {
2020-04-22 15:17:25 +02:00
if (genID === true) {
$ alias . el . value = alias + "-" + randStr(4);
doneTyping();
return;
}
2020-01-16 19:13:33 +01:00
aliasOK = false;
$ alias . setClass ('error');
$ aliasSite . className = 'error';
$ aliasSite . textContent = data.error_msg;
}
}
}
http.send(JSON.stringify(params));
} else {
$ aliasSite . className += ' demo';
$ aliasSite . innerHTML = '{{ if .Federation }}@<strong>your-username</strong>@{{.FriendlyHost}}{{ else }}{{.FriendlyHost}}/<strong>your-username</strong>/{{ end }}';
}
};
$ alias . on ('keyup input', function() {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
2020-04-22 15:17:25 +02:00
function randStr(len) {
var res = '';
var chars = '23456789bcdfghjklmnpqrstvwxyz';
for (var i=0; i<len; i++) {
res += chars.charAt(Math.floor(Math.random() * chars.length));
}
return res;
}
doneTyping(true);
2020-01-02 21:33:39 +01:00
</script>
{{end}}