login works now

This commit is contained in:
Ulf Gebhardt 2016-01-04 05:05:45 +01:00
parent f436394d43
commit d0d0993e1b
4 changed files with 48 additions and 1 deletions

View File

@ -1,6 +1,10 @@
<?php
class default_login extends \SYSTEM\PAGE\Page {
public static function js(){
return array(\SYSTEM\WEBPATH(new \PPAGE(),'default_login/js/default_login.js'));}
public function html(){
return SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PPAGE(),'default_login/tpl/login.tpl'), \SYSTEM\PAGE\text::tag('mojotrollz'));
return \SYSTEM\SECURITY\Security::isLoggedIn() ?
\SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PPAGE(),'default_login/tpl/loggedin.tpl'), \SYSTEM\PAGE\text::tag('mojotrollz'))
: \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PPAGE(),'default_login/tpl/loggedout.tpl'), \SYSTEM\PAGE\text::tag('mojotrollz'));
}
}

View File

@ -0,0 +1,33 @@
function init_login(){
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get('./api.php?call=account&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
if(data == 1){
$('.help-block').html("Login successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.")
}
});
event.preventDefault();
}
});
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
$.get('./api.php?call=account&action=logout', function (data) {
if(data == 1){
$('.help-block').html("Logout successfull.</br>");
location.reload(true);
} else {
$('.help-block').html("Logout not successfull.</br>")
}
});
event.preventDefault();
}
});
}

View File

@ -0,0 +1,10 @@
<div class="mojotrollz_col_content">
<h2>You are logged in</h2>
<form class="textbox" style="padding:10px" id="logout_form">
<div class="control-group">
<div class="help-block"></div>
<input type="hidden" />
<button class="btn-sm btn btn-primary" style="width: 250px;" type="submit" id="logout_submit"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> ${basic_logout}</button>
</div>
</form>
</div>