Main Page
Namespaces
Classes
Files
File List
src
webui
mod
login
cgibin
signin_lobby.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
3
import
nstart
4
import
config
5
import
os, sys, string, time
6
import
socket
7
8
from
pyclearsilver.log
import
*
9
10
from
pyclearsilver.CSPage
import
Context
11
import
neo_cgi, neo_cs, neo_util
12
from
MBPage
import
MBPage
13
from
webui
import
config
14
15
from
auth
import
browserauth
16
from
auth
import
cookieauth
17
from
auth
import
db_auth
18
from
auth
import
pwauth
19
20
from
web_msgs.msg
import
WebEvent
21
import
rospy
22
23
class
SignInPage
(MBPage):
24
def
setup
(self, hdf):
25
pass
26
27
def
display
(self, hdf):
28
username = hdf.getValue(
"Query.username"
,
""
)
29
if
not
username:
return
30
31
# need to check ip address is coming from the lobby
32
# lobby address is in config
33
ip_address = socket.gethostbyname(config.gLobbyHost)
34
35
if
hdf.getValue(
"CGI.RemoteAddress"
,
""
) != ip_address:
36
warn(
"request from lobby on %s does not match %s"
% (hdf.getValue(
"CGI.RemoteAddress"
,
""
), ip_address))
37
return
38
else
:
39
warn(
"ip address is authorized"
)
40
41
# create the user record and transfer all info
42
user = self.authdb.users.lookupCreate(username=username)
43
44
for
key
in
(
"role"
,
"pw_hash"
,
"status"
,
"dismissed_notices"
,
"favorite_apps"
,
"skype_id"
):
45
user[key] = hdf.getValue(
"Query."
+ key,
""
)
46
47
user.save()
48
49
# write the active user file
50
self.
username
= username
51
self.make_active_user(hdf)
52
53
# publish a web event that we logged in
54
pub = rospy.Publisher(
"/webui/events"
, WebEvent)
55
rospy.init_node(
"webui_login"
, anonymous=
True
)
56
msg = WebEvent()
57
msg.source =
"user"
58
msg.type =
"login (lobby)"
59
msg.data = self.
username
60
pub.publish(msg)
61
62
63
def
run
(context):
64
page =
SignInPage
(context, pagename=
"signin_lobby"
, nologin=1)
65
return
page
66
67
def
main
(context):
68
page =
run
(context)
69
page.start()
70
71
72
if
__name__ ==
"__main__"
:
73
main
(
Context
())
74
pyclearsilver::log
webui.mod.login.cgibin.signin_lobby.SignInPage
Definition:
signin_lobby.py:23
webui.mod.login.cgibin.signin_lobby.SignInPage.setup
def setup(self, hdf)
Definition:
signin_lobby.py:24
webui.mod.login.cgibin.signin_lobby.main
def main(context)
Definition:
signin_lobby.py:67
web_msgs::msg
pyclearsilver::CSPage::Context
webui.mod.login.cgibin.signin_lobby.SignInPage.display
def display(self, hdf)
Definition:
signin_lobby.py:27
pyclearsilver::CSPage
webui.mod.login.cgibin.signin_lobby.SignInPage.username
username
Definition:
signin_lobby.py:50
webui.mod.login.cgibin.signin_lobby.run
def run(context)
Definition:
signin_lobby.py:63
webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24