Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
4a3f9528
Commit
4a3f9528
authored
2 years ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
relocate relevant code from Seminar_Auth to Seminar_Register_Auth, fixes #1275
Closes #1275 Merge request
studip/studip!781
parent
89512696
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/phplib/Seminar_Auth.class.php
+47
-88
47 additions, 88 deletions
lib/phplib/Seminar_Auth.class.php
lib/phplib/Seminar_Register_Auth.class.php
+34
-8
34 additions, 8 deletions
lib/phplib/Seminar_Register_Auth.class.php
with
81 additions
and
96 deletions
lib/phplib/Seminar_Auth.class.php
+
47
−
88
View file @
4a3f9528
...
...
@@ -30,12 +30,6 @@ class Seminar_Auth
*/
protected
$persistent_slots
=
[
"auth"
,
"classname"
];
/**
* @var string
*/
protected
$mode
=
"log"
;
## "log" for login only systems,
## "reg" for user self registration
/**
* @var bool
*/
...
...
@@ -74,22 +68,20 @@ class Seminar_Auth
}
}
/**
* @return bool
* @throws RuntimeException
* Check current auth state. Should be one of
* 1) Not logged in (no valid auth info or auth expired)
* 2) Logged in (valid auth info)
* 3) Login in progress (if $this->cancel_login, revert to state 1)
* @return int
*/
function
start
()
protected
function
getState
():
int
{
global
$sess
;
# Check current auth state. Should be one of
# 1) Not logged in (no valid auth info or auth expired)
# 2) Logged in (valid auth info)
# 3) Login in progress (if $this->cancel_login, revert to state 1)
if
(
$this
->
is_authenticated
())
{
$uid
=
$this
->
auth
[
"
uid
"
];
$uid
=
$this
->
auth
[
'
uid
'
];
switch
(
$uid
)
{
case
"
form
"
:
case
'
form
'
:
# Login in progress
if
(
Request
::
option
(
$this
->
cancel_login
))
{
# If $this->cancel_login is set, delete all auth info and set
...
...
@@ -113,7 +105,18 @@ class Seminar_Auth
$state
=
1
;
}
switch
(
$state
)
{
return
$state
;
}
/**
* @return bool
* @throws RuntimeException
*/
public
function
start
()
{
global
$sess
;
switch
(
$this
->
getState
())
{
case
1
:
# No valid auth info or auth is expired
...
...
@@ -126,87 +129,43 @@ class Seminar_Auth
return
true
;
}
# Check for "log" vs. "reg" mode
switch
(
$this
->
mode
)
{
case
"yes"
:
case
"log"
:
if
(
$this
->
nobody
)
{
# Authenticate as nobody
$this
->
auth
[
"uid"
]
=
"nobody"
;
return
true
;
}
else
{
# Show the login form
$this
->
auth_loginform
();
$this
->
auth
[
"uid"
]
=
"form"
;
$sess
->
freeze
();
exit
;
}
break
;
case
"reg"
:
if
(
$this
->
nobody
)
{
# Authenticate as nobody
$this
->
auth
[
"uid"
]
=
"nobody"
;
return
true
;
}
else
{
# Show the registration form
$this
->
auth_registerform
();
$this
->
auth
[
"uid"
]
=
"form"
;
exit
;
}
break
;
default
:
# This should never happen. Complain.
throw
new
RuntimeException
(
"Error in auth handling: no valid mode specified."
);
if
(
$this
->
nobody
)
{
# Authenticate as nobody
$this
->
auth
[
"uid"
]
=
"nobody"
;
return
true
;
}
else
{
# Show the login form
$this
->
auth_loginform
();
$this
->
auth
[
"uid"
]
=
"form"
;
$sess
->
freeze
();
exit
;
}
break
;
case
2
:
# Valid auth info
# do nothin
break
;
case
3
:
# Login in progress, check results and act accordingly
switch
(
$this
->
mode
)
{
case
"yes"
:
case
"log"
:
if
(
$uid
=
$this
->
auth_validatelogin
())
{
$this
->
auth
[
"uid"
]
=
$uid
;
$keep_session_vars
=
[
'auth'
,
'forced_language'
,
'_language'
,
'contrast'
];
if
(
$this
->
auth
[
'perm'
]
===
'root'
)
{
$keep_session_vars
[]
=
'plugins_disabled'
;
}
$sess
->
regenerate_session_id
(
$keep_session_vars
);
$sess
->
freeze
();
$GLOBALS
[
'user'
]
=
new
Seminar_User
(
$this
->
auth
[
'uid'
]);
return
true
;
}
else
{
$this
->
auth_loginform
();
$this
->
auth
[
"uid"
]
=
"form"
;
$sess
->
freeze
();
exit
;
}
break
;
case
"reg"
:
if
(
$uid
=
$this
->
auth_doregister
())
{
$this
->
auth
[
"uid"
]
=
$uid
;
$GLOBALS
[
'user'
]
=
new
Seminar_User
(
$this
->
auth
[
'uid'
]);
return
true
;
}
else
{
$this
->
auth_registerform
();
$this
->
auth
[
"uid"
]
=
"form"
;
$sess
->
freeze
();
exit
;
}
break
;
default
:
# This should never happen. Complain.
throw
new
RuntimeException
(
"Error in auth handling: no valid mode specified."
);
break
;
$uid
=
$this
->
auth_validatelogin
();
if
(
$uid
)
{
$this
->
auth
[
"uid"
]
=
$uid
;
$keep_session_vars
=
[
'auth'
,
'forced_language'
,
'_language'
,
'contrast'
];
if
(
$this
->
auth
[
'perm'
]
===
'root'
)
{
$keep_session_vars
[]
=
'plugins_disabled'
;
}
$sess
->
regenerate_session_id
(
$keep_session_vars
);
$sess
->
freeze
();
$GLOBALS
[
'user'
]
=
new
Seminar_User
(
$this
->
auth
[
'uid'
]);
return
true
;
}
else
{
$this
->
auth_loginform
();
$this
->
auth
[
"uid"
]
=
"form"
;
$sess
->
freeze
();
exit
;
}
break
;
default
:
# This should never happen. Complain.
throw
new
RuntimeException
(
"Error in auth handling: invalid state reached."
);
break
;
}
return
false
;
...
...
This diff is collapsed.
Click to expand it.
lib/phplib/Seminar_Register_Auth.class.php
+
34
−
8
View file @
4a3f9528
...
...
@@ -15,16 +15,42 @@
*/
class
Seminar_Register_Auth
extends
Seminar_Auth
{
/**
* @var string
*/
protected
$mode
=
'reg'
;
public
function
start
()
{
global
$sess
;
switch
(
$this
->
getState
())
{
# No valid auth info or auth is expired
case
1
:
if
(
$this
->
nobody
)
{
# Authenticate as nobody
$this
->
auth
[
'uid'
]
=
'nobody'
;
return
true
;
}
else
{
# Show the registration form
$this
->
auth_registerform
();
$this
->
auth
[
'uid'
]
=
'form'
;
exit
;
}
# Login in progress, check results and act accordingly
case
3
:
$uid
=
$this
->
auth_doregister
();
if
(
$uid
)
{
$this
->
auth
[
'uid'
]
=
$uid
;
$GLOBALS
[
'user'
]
=
new
Seminar_User
(
$this
->
auth
[
'uid'
]);
return
true
;
}
else
{
$this
->
auth_registerform
();
$this
->
auth
[
'uid'
]
=
'form'
;
$sess
->
freeze
();
exit
;
}
}
public
$error_msg
=
''
;
return
parent
::
start
();
}
/**
*
*/
public
function
auth_registerform
()
{
$this
->
check_environment
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment