Convert login page
FossilOrigin-Name: f61018fe4ab711036008fc1b24b27c4c1fa2fa249ee19932d943351f5a9dbc43
This commit is contained in:
parent
8fae1ddfe9
commit
bbdb95187b
6 changed files with 66 additions and 16 deletions
|
@ -1,7 +1,6 @@
|
|||
package account;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
|
||||
use Exporter 'import';
|
||||
|
||||
|
|
22
perl/login.pm
Normal file
22
perl/login.pm
Normal file
|
@ -0,0 +1,22 @@
|
|||
package login;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Exporter 'import';
|
||||
|
||||
our @EXPORT = qw( content_login );
|
||||
|
||||
use template_helpers 'to_template';
|
||||
|
||||
sub content_login
|
||||
{
|
||||
my ($ssn, $data, $error) = @_;
|
||||
|
||||
my %vars = (
|
||||
error => $error,
|
||||
);
|
||||
|
||||
to_template(\%vars, \$data->{'login.tt'});
|
||||
}
|
||||
|
||||
1;
|
|
@ -15,6 +15,7 @@ use chat;
|
|||
use config;
|
||||
use embed;
|
||||
use meta;
|
||||
use login;
|
||||
|
||||
# my $template = Template->new(
|
||||
# {
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "../templates/notifs_embed.ctt"
|
||||
#include "../templates/about.ctt"
|
||||
#include "../templates/license.ctt"
|
||||
#include "../templates/login.ctt"
|
||||
|
||||
PerlInterpreter* my_perl;
|
||||
HV* template_files;
|
||||
|
@ -88,6 +89,7 @@ void init_template_files(pTHX)
|
|||
hv_stores(template_files, "notifs_embed.tt", newSVpv(data_notifs_embed_tt, data_notifs_embed_tt_size));
|
||||
hv_stores(template_files, "about.tt", newSVpv(data_about_tt, data_about_tt_size));
|
||||
hv_stores(template_files, "license.tt", newSVpv(data_license_tt, data_license_tt_size));
|
||||
hv_stores(template_files, "login.tt", newSVpv(data_login_tt, data_login_tt_size));
|
||||
}
|
||||
|
||||
void cleanup_template_files()
|
||||
|
|
27
src/login.c
27
src/login.c
|
@ -206,23 +206,21 @@ void content_login(PATH_ARGS)
|
|||
}
|
||||
}
|
||||
|
||||
// Concat
|
||||
struct login_template tdata = {
|
||||
.login_header = L10N[L10N_EN_US][L10N_LOGIN],
|
||||
.error = error,
|
||||
.prefix = config_url_prefix,
|
||||
.username = L10N[L10N_EN_US][L10N_USERNAME],
|
||||
.password = L10N[L10N_EN_US][L10N_PASSWORD],
|
||||
.login_submit = L10N[L10N_EN_US][L10N_LOGIN_BTN],
|
||||
.instance_text = "Or",
|
||||
.instance_url = "Instance url",
|
||||
.instance_submit = "Authorize"
|
||||
};
|
||||
page = tmpl_gen_login(&tdata, NULL);
|
||||
PERL_STACK_INIT;
|
||||
HV* session_hv = perlify_session(ssn);
|
||||
XPUSHs(newRV_noinc((SV*)session_hv));
|
||||
XPUSHs(newRV_noinc((SV*)template_files));
|
||||
if (storage.error || oauth_store.error)
|
||||
XPUSHs(newSVpv(storage.error ? storage.error : oauth_store.error, 0));
|
||||
|
||||
PERL_STACK_SCALAR_CALL("login::content_login");
|
||||
|
||||
page = PERL_GET_STACK_EXIT;
|
||||
|
||||
struct base_page b = {
|
||||
.category = BASE_CAT_NONE,
|
||||
.content = page,
|
||||
.session = session_hv,
|
||||
.sidebar_left = NULL
|
||||
};
|
||||
|
||||
|
@ -232,6 +230,5 @@ void content_login(PATH_ARGS)
|
|||
// Cleanup
|
||||
mastodont_storage_cleanup(&storage);
|
||||
mastodont_storage_cleanup(&oauth_store);
|
||||
if (error) free(error);
|
||||
if (page) free(page);
|
||||
Safefree(page);
|
||||
}
|
||||
|
|
29
templates/login.tt
Normal file
29
templates/login.tt
Normal file
|
@ -0,0 +1,29 @@
|
|||
<div class="simple-page">
|
||||
<h1>{{%s:login_header}}</h1>
|
||||
|
||||
{{%s:error}}
|
||||
|
||||
<form action="/login" method="post">
|
||||
<div class="form-group">
|
||||
<label for="login-username">{{%s:username}}: </label>
|
||||
<input type="text" id="login-username" name="username">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="login-password">{{%s:password}}: </label>
|
||||
<input type="password" id="login-password" name="password"><br>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="btn" type="submit" value="{{%s:login_submit}}">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h6>{{%s:instance_text}}</h6>
|
||||
|
||||
<form action="/login/oauth" method="post">
|
||||
<div class="form-group">
|
||||
<label for="instance-url">{{%s:instance_url}}: </label>
|
||||
<input type="url" id="instance-url" name="instance">
|
||||
<input class="btn" type="submit" value="{{%s:instance_submit}}">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in a new issue