mod/webui/cgibin/newuser.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """
4 usage: %(progname)s [args]
5 """
6 
7 import nstart
8 
9 import os, sys, string, time, getopt, re
10 from pyclearsilver.log import *
11 
12 import neo_cgi, neo_util, neo_cs
13 
14 from pyclearsilver import CSPage
15 from pyclearsilver import odb
16 
17 import MBPage
18 import db_webui
19 
20 import roslib
21 import roslib.scriptutil
22 #import rospy
23 import webutil
24 
26  def setup(self, hdf):
27  self.db = db_webui.initSchema()
28 
29  def display(self, hdf):
30  webutil.set_tabs(hdf, ["admin", "users"])
31 
32  def Action_CreateUser(self, hdf):
33  # load params from request
34  username = hdf.getValue("Query.username", "").strip()
35  password = hdf.getValue("Query.password", "").strip()
36  role = hdf.getValue("Query.role", "").strip()
37 
38  # check some error conditions
39  if self.authdb.users.lookup(username=username):
40  hdf.setValue("CGI.cur.error_message.username", "User %s already exists." % username)
41  if len(username) < 3:
42  hdf.setValue("CGI.cur.error_message.username", "Please specify a user name (3 or more characters).")
43  if len(password) < 3:
44  hdf.setValue("CGI.cur.error_message.password", "Please specify a password (3 or more characters).")
45  if hdf.getObj("CGI.cur.error_message"):
46  return
47 
48  # save the new user record
49  try:
50  row = self.authdb.users.newRow()
51  row.username = hdf.getValue("Query.username", "")
52  new_password = hdf.getValue("Query.password", "")
53  row.setPassword(new_password)
54  row.role = hdf.getValue("Query.role", "")
55  row.save()
56  except:
57  hdf.setValue("CGI.cur.error_message.password", "There was an error when trying to save this user.")
58 
59  self.redirectUri("users.py")
60 
61 def run(context):
62  return MyPage(context, pagename="newuser", nologin=False)
63 
64 def main():
65  context = CSPage.Context()
66  run(context).start()
67 
68 if __name__ == "__main__":
69  main()
def redirectUri(self, redirectTo)


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24