Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
3bca7331
Commit
3bca7331
authored
Oct 13, 2014
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added auto-login option that lasts for 2 weeks
parent
10e32f5c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
app.php
app.php
+4
-0
config.json
config.json
+1
-0
routes/common.php
routes/common.php
+8
-2
No files found.
app.php
View file @
3bca7331
...
...
@@ -89,6 +89,9 @@ $app->hook('slim.before.router', function () use ($app, $user) {
$app
->
redirect
(
ROOT_URL
.
'/login'
);
});
// Extend maximum session lifetime to allow auto-login
$session
->
setExpiration
(
$config
[
'max_session_lifetime'
]);
/*
* Routes
*/
...
...
@@ -98,5 +101,6 @@ require 'routes/register.php';
require
'routes/user.php'
;
require
'routes/match.php'
;
// Certain globals should be available in all templates
$view
->
replace
(
compact
(
'app'
,
'config'
,
'user'
));
$app
->
run
();
config.json
View file @
3bca7331
...
...
@@ -2,6 +2,7 @@
"database"
:
{
"lazy"
:
true
},
"max_session_lifetime"
:
"2 weeks"
,
"log.enable"
:
true
,
"debug"
:
false
}
routes/common.php
View file @
3bca7331
...
...
@@ -16,7 +16,7 @@ function login_form() {
->
setRequired
();
$form
->
addPassword
(
'password'
,
_
(
'Password'
))
->
setRequired
();
//
$form->addCheckbox('remember', _('Remember me'));
$form
->
addCheckbox
(
'remember'
,
_
(
'Remember me'
));
$form
->
addSubmit
(
'send'
,
_
(
'Login'
));
return
$form
;
...
...
@@ -29,7 +29,7 @@ $app->get('/login', function () use ($app, $user) {
$app
->
render
(
'login'
,
array
(
'form'
=>
login_form
()));
});
$app
->
post
(
'/login'
,
function
()
use
(
$
app
,
$user
)
{
$app
->
post
(
'/login'
,
function
()
use
(
$
config
,
$app
,
$user
,
$session
)
{
$form
=
login_form
();
$form
->
validate
();
...
...
@@ -38,6 +38,12 @@ $app->post('/login', function () use ($app, $user) {
try
{
$user
->
login
(
$values
->
username
,
$values
->
password
);
if
(
$values
->
remember
)
$user
->
setExpiration
(
$config
[
'max_session_lifetime'
],
false
);
else
$user
->
setExpiration
(
0
,
true
);
$app
->
redirect
(
ROOT_URL
);
}
catch
(
Nette\Security\AuthenticationException
$e
)
{
$form
->
addError
(
$e
->
getMessage
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment