Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
13e53601
Commit
13e53601
authored
Aug 30, 2015
by
woogerboy21
Browse files
Merge pull request #1442 from woogerboy21/fix_oldsession
Fix bug that crashes server when old session is logged out during login
parents
8bb6bb04
66dce1bf
Changes
1
Show whitespace changes
Inline
Side-by-side
common/server.cpp
View file @
13e53601
...
...
@@ -111,8 +111,6 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
Server_DatabaseInterface
*
databaseInterface
=
getDatabaseInterface
();
QWriteLocker
locker
(
&
clientsLock
);
AuthenticationResult
authState
=
databaseInterface
->
checkUserPassword
(
session
,
name
,
password
,
clientid
,
reasonStr
,
secondsLeft
);
if
(
authState
==
NotLoggedIn
||
authState
==
UserIsBanned
||
authState
==
UsernameInvalid
||
authState
==
UserIsInactive
)
return
authState
;
...
...
@@ -121,14 +119,10 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
data
.
set_address
(
session
->
getAddress
().
toStdString
());
name
=
QString
::
fromStdString
(
data
.
name
());
// Compensate for case indifference
databaseInterface
->
lockSessionTables
();
if
(
authState
==
PasswordRight
)
{
// verify that new session would not cause problems with older existing session
if
(
users
.
contains
(
name
)
||
databaseInterface
->
userSessionExists
(
name
))
{
if
(
users
.
contains
(
name
))
{
qDebug
(
"Session already logged in, logging old session out"
);
Event_ConnectionClosed
event
;
event
.
set_reason
(
Event_ConnectionClosed
::
LOGGEDINELSEWERE
);
event
.
set_reason_str
(
"You have been logged out due to logging in at another location."
);
...
...
@@ -138,7 +132,10 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
users
.
value
(
name
)
->
sendProtocolItem
(
*
se
);
delete
se
;
users
.
value
(
name
)
->
prepareDestroy
();
}
}
}
else
if
(
authState
==
UnknownUser
)
{
// Change user name so that no two users have the same names,
// don't interfere with registered user names though.
...
...
@@ -156,6 +153,8 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
data
.
set_name
(
name
.
toStdString
());
}
QWriteLocker
locker
(
&
clientsLock
);
databaseInterface
->
lockSessionTables
();
users
.
insert
(
name
,
session
);
qDebug
()
<<
"Server::loginUser:"
<<
session
<<
"name="
<<
name
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment