5 import os, sys, string, time
10 import neo_cgi, neo_cs, neo_util
11 from MBPage
import MBPage
13 from auth
import browserauth
14 from auth
import cookieauth
15 from auth
import db_auth
16 from auth
import pwauth
18 from pyclearsilver
import wordwrap
19 from email
import MIMEText, Generator, Parser
20 from cStringIO
import StringIO
31 q_signout = hdf.getIntValue(
"Query.signout",0)
32 self.
requestURI = hdf.getValue(
"Query.request",
"")
34 hdf.setValue(
"CGI.cur.request", self.
requestURI)
37 cookieauth.clearLoginCookie(self.ncgi, self.username)
40 self.redirectUri(self.default_app_path())
44 requestURI = hdf.getValue(
"CGI.RequestURI",
"")
45 rurl = config.gBaseURL +
"login/changePassword.py" 46 self.redirectUri(rurl +
"?q=1&request=" + neo_cgi.urlEscape(config.gBaseURL +
"webui/"))
49 warn(
"action logout called")
51 self.ncgi.cookieClear(
"inactive")
53 if self.is_active_user():
54 warn(
"removing active user")
55 self.remove_active_user()
57 warn(
"logging out non-active user")
60 pub = rospy.Publisher(
"/webui/events", WebEvent)
61 rospy.init_node(
"webui_login", anonymous=
True)
65 msg.data = self.username
68 if config.get_robot_type().startswith(
"texas"):
69 self.redirectUri(config.gLobbyReturnPage +
"?robot_name=" + hdf.getValue(
'CGI.Robot',
""))
72 domain = hdf.getValue(
"HTTP.Host",
"")
73 cookieauth.clearLoginCookie(self.ncgi, self.username, domain)
74 self.redirectUri(self.default_app_path())
78 q_username = hdf.getValue(
"Query.username",
"")
79 q_passwordHash = hdf.getValue(
"Query.password",
"")
80 q_persist = hdf.getValue(
"Query.persist",
"0")
82 try: q_persist = int(q_persist)
83 except ValueError: q_persist = 0
85 default_requestURI = config.gBaseURL +
"%s/" % config.gDefaultModule
93 wwwhostname = hdf.getValue(
"HTTP.Host",
"")
95 rurl = self.http + wwwhostname + config.gBaseURL +
"login/signin0.py" 97 warn(
"signin.py", rurl)
100 userRec = self.authdb.users.lookup(q_username)
103 warn(
"signin.py",
"login failure (%s) unknown user" % q_username)
104 self.redirectUri(rurl +
"?err=Invalid+Login&request=%s" % neo_cgi.urlEscape(self.
requestURI))
106 q_password = pwauth.unmungePassword(q_passwordHash)
108 ipaddr = hdf.getValue(
"CGI.RemoteAddress",
"Unknown")
109 browserid = browserauth.getBrowserCookie(self.ncgi)
115 loginRow = self.authdb.login.newRow()
116 loginRow.uid = userRec.uid
117 loginRow.username = userRec.username
118 loginRow.ipaddr = ipaddr
119 loginRow.browserid = browserid
121 if userRec.checkPassword(q_password) == 0:
122 warn(
"signin.py",
"login failure (%s) password mismatch" % q_username, q_password)
123 loginRow.loginType = 0
127 url = rurl +
"?err=Invalid+Login&request=%s" % neo_cgi.urlEscape(self.
requestURI)
128 warn(
"redirecting to", url)
129 self.redirectUri(url)
135 loginRow.loginType = 1
138 cookieauth.issueLoginCookie(self.ncgi, self.
authdb, q_username, userRec.pw_hash, q_persist)
140 if userRec.changePassword == 1:
145 pub = rospy.Publisher(
"/webui/events", WebEvent)
146 rospy.init_node(
"webui_login", anonymous=
True)
149 msg.type =
"login (local)" 150 msg.data = self.username
164 page =
SignInPage(context, pagename=
"signin",nologin=1)
172 if __name__ ==
"__main__":
def Action_Logout(self, hdf)
def requestChangePassword(self)
def Action_Login(self, hdf)