def on_register_button(self): u = self.dialog.lineEdit.text() p = self.dialog.lineEdit_2.text() e = self.dialog.lineEdit_3.text() n = self.dialog.lineEdit_4.text() db.createUser(u, p, e, n)
def __init__(self, username): avatar.ConchUser.__init__(self) self.username = username self.listeners = {} self.pubkey = PublicKeyCredentialsChecker.instance.getKey(username) self.isannon = PublicKeyCredentialsChecker.instance.isAnnon(username) self.channelLookup.update({ 'session': session.SSHSession, 'direct-tpcip': openConnectForwardingClient }) if self.isannon: if config["ANNONYMOUS_TIMEOUT"] > 0: repeater = LoopingCall(AnnonTimeout, user=self) repeater.kw['loop'] = repeater repeater.start(config["ANNONYMOUS_TIMEOUT"] * MINUTES, now=False) if not database.getUser(key=self.pubkey): database.createUser(key=self.pubkey, username=self.username, enabled=not self.isannon) # log user logged in database.updateUserLastLogin(key=self.pubkey) ForwardUser.loggedin[self] = time()
def __init__(self, username): avatar.ConchUser.__init__(self) self.username = username self.listeners={} self.pubkey = PublicKeyCredentialsChecker.instance.getKey(username) self.isannon = PublicKeyCredentialsChecker.instance.isAnnon(username) self.channelLookup.update({ 'session':session.SSHSession, 'direct-tpcip': openConnectForwardingClient }) if self.isannon: if config["ANNONYMOUS_TIMEOUT"] > 0: repeater=LoopingCall(AnnonTimeout, user=self) repeater.kw['loop']=repeater repeater.start(config["ANNONYMOUS_TIMEOUT"]*MINUTES, now=False) if not database.getUser(key=self.pubkey): database.createUser(key=self.pubkey, username=self.username, enabled=not self.isannon) # log user logged in database.updateUserLastLogin(key=self.pubkey) ForwardUser.loggedin[self]=time()
def _onSetRegister(self, iq): fromjid = jid.internJID(iq["from"]) data = iq.query username = None password = None phone = None msgtype = "message" report = False if data.x == None: """ use standard form if no xdata is returned """ username = data.username password = data.password phone = data.phone else: """ xdata available, take it! """ for field in data.x.elements(): if field.name == "field": if field.getAttribute("var") == "username": username = str(field.value) if field.getAttribute("var") == "smstype": smstyp = str(field.value) if field.getAttribute("var") == "password": password = str(field.value) if field.getAttribute("var") == "phone": phone = str(field.value) if field.getAttribute("var") == "msgtype": msgtype = str(field.value) if field.getAttribute("var") == "report": report = str(field.value) # set password to None if there isn't one if password == "": password = None # remove or register? if data.remove == None: # register new account database.createUser(fromjid, username, phone, password) # set the default message type if set if smstyp != None: database.setDefaultMessageType(fromjid, smstyp) database.setMessageAsChat(fromjid, (msgtype == "chat")) database.setReportRequested(fromjid, (report == "yes")) # send own subscribe self.send(Presence(to=fromjid, type='subscribe')) # create welcome message httpkey = database.getHTTPGetKey(fromjid.userhost()) welcomemsg = messages.getInfoMessage("welcome", str(fromjid.userhost()), httpkey) # send welcome message welcome = domish.Element((None, "message")) welcome["to"] = iq["from"] welcome.addElement("subject", content=welcomemsg[0]) welcome.addElement("body", content=welcomemsg[1]) self.send(welcome) else: # remove the account database.removeUser(fromjid)
def github_login(): if not github.authorized: return redirect(url_for('github.login')) else: account_info = github.get('/user') if account_info.ok: account_info_json = account_info.json() print("account info json", account_info_json) with app.app_context(): user = { "username": "******", "email": "*****@*****.**", "login": account_info_json['login'], "location": account_info_json['location'], "roleid": "" } db = database.createUser(user) print("user in db is...", db) if db: role = database.getRole(db['roleid']) if role: # token=generate_token.generateToken(account_info_json['name'],role['role']) token = generate_token.generateToken( db['username'], role['role']) print("token is...", token) session['bearerToken'] = token session['username'] = account_info_json['login'] rendered = render_template('blog.html', \ session=session) return rendered # return '<h1>Your Github name is {}'.format(account_info_json['login']) return '<h1>Request failed!</h1>'
def create(): defenses.setup(request, response) csrftoken = defenses.csrfDefense.init(request, response) defenses.csrfDefense.validate(request, csrftoken) username = request.forms.get("username") password = request.forms.get("password") if not username or not password: raise HTTPError(400, "Required field is empty") if not re.match("[A-Za-z0-9]+$", username): raise HTTPError(400, "Invalid username") if database.fetchUser(username): raise HTTPError(400, "User already exists") if len(password) < 4: raise HTTPError(400, "Password too short") database.createUser(username, password) if not database.validateUser(username, password): raise HTTPError(403, "Account creation unsuccessful") response.set_cookie("authuser", username, authSecret, httponly=True) redirect("./")
def newUser(my_database): email = raw_input("Enter email address: ") npi = raw_input("Enter npi number: ") vault = raw_input("Enter vault id: ") api = raw_input("Enter api id: ") name = raw_input("Enter name: ") pw = raw_input("Enter password: "******"Enter organization: ") data = [email, npi, vault, api, name, pw, org] return database.createUser(my_database, data)
def login(create=False): defenses.setup(request, response) csrftoken = defenses.csrfDefense.init(request, response) defenses.csrfDefense.validate(request, csrftoken) username = request.forms.get("username") password = request.forms.get("password") if not username or not password: raise HTTPError(400, "Required field is empty") if not re.match("[A-Za-z0-9]+$", username): raise HTTPError(400, "Invalid username") if create: if database.fetchUser(username): raise HTTPError(400, "User already exists") if len(password) < 4: raise HTTPError(400, "Password too short") database.createUser(username, password) if not database.validateUser(username, password): raise HTTPError(403, "Login unsuccessful") response.set_cookie("authuser", username, authSecret, httponly=True) redirect("./")
def addUser(): content = request.json # print(content) if all(keys in content for keys in ('username', 'password')) and len(content) == 2: _p = hashlib.md5(content['password'].encode()) content['password'] = _p.hexdigest() if db.createUser(content): return jsonify({'status': 'account created'}) # jsonify({'status': 'unable to create account'}), return Response(status=400)
def getUser(name, create=True): dbEntry = database.getUser(name) if not dbEntry: if not create: return userState(None) # Create a new database entry for us dbEntry = database.createUser(name) if not dbEntry: raise AssertionError( "User still doesn't exist after just creating it????") return userState(dbEntry)
def register(): try: session["logged_in"] except KeyError: session["logged_in"] = False if not session["logged_in"]: if request.method == "GET": return render_template("auth/register.html") elif request.method == "POST": username = request.form["username"] password = request.form["password"] password_hashed = bcrypt.hashpw(password.encode('utf8'), bcrypt.gensalt()) if not usernameExists(username, dbPath): createUser(username, password_hashed, dbPath) return redirect(url_for("login")) else: return render_template("auth/register.html", invalid=True) else: return redirect(url_for("index"))
def register(): data = request.get_json() username = data['username'] password = data['password'] result = findUser(username) if result: return {'errcode': 400, 'errmsg': '该用户已被注册'} else: rowcount = createUser(username, password) if rowcount > 0: return {'errcode': 0, 'errmsg': '注册成功'} else: return {'errcode': 1, 'errmsg': '注册失败'}
def register(): data = request.get_json() username = data['username'] password = data['password'] result = findUser(username) if result: return {'errcode': 400, 'errmsg': '该用户名已被注册'}, 400 rowcount = createUser(username, password) if rowcount > 0: return {'errcode': 0, 'errmsg': '注册成功'}, 200 return {'errcode': 400, 'errmsg': '请检查网络或其他设置'}, 400
def post(self,*args,**kwargs): if self.request.headers['Content-Type'] == 'application/json': data=json.loads(self.request.body) phone=data['phone'] password=data['password'] nickname=data['nick_name'] result=findUser(phone) if result: msg={'errcode':1,'errmsg':'手机号已被注册!'} elif(result==checkPhone(phone)): msg={'errcode':1,'errmsg':'请输入正确的手机号!'} else: result=createUser(phone,password,nickname) if result: msg={'errcode':0,'errmsg':'注册成功!'} self.write(json.dumps(msg))
def register(): data = request.get_json() someone = student() someone.name = data['name'] someone.sex = data['sex'] someone.grade = data['grade'] someone.college = data['college'] someone.dormitory = data['dormitory'] someone.first = data['first'] someone.second = data['second'] someone.tel = data['tel'] someone.adjust = data['adjust'] someone.description = data['description'] ret = re.match(r"^1\d{10}$", someone.tel) isRegister = findTel(someone.tel) if ret: if isRegister: return { "status": 409, "msg": "该手机号已报名", "data": null } else: rowCount = createUser(someone) if rowCount > 0: return { "status": 200, "msg": "报名成功", "data": null } else: return { "status": 410, "msg": "服务器错误", "data": null } else: return { "status": 400, "msg": "手机号错误或是其他参数错误", "data": null }
def register(): data = request.get_json() phone = data['phone'] nick_name = data['nick_name'] password = data['password'] result = checkPhone(phone) if (result['phoneLength'] == True): if (result['uniqueness'] == False): return {'errcode': 400, 'errmsg': '该手机已被填写'}, 400 elif (result['phoneLength'] == False): return {'errcode': 400, 'errmsg': '手机号格式不正确'}, 400 rowcount = createUser(nick_name, phone, password) if rowcount > 0: return {'errcode': 0, 'errmsg': '注册成功'}, 200 return {'errcode': 400, 'errmsg': '请检查网络或其他设置'}, 400
def register():#用户注册 #获取前端数据 data = request.get_json() username = data['username'] password = data['password'] result = findUser(username) if result: return{ 'errcode':400, 'errmsg': '该用户已被注册' },400 rowcount = createUser(username, password) if rowcount > 0: return { 'errcode': 0, 'errmsg': '注册成功' }, 200 return { 'errcode': 400, 'errmsg': '出现错误,请重试' },400
def POST(self): input = web.input() if (input.funcname == "createUser"): ret = database.createUser(input.username, input.email, input.password) return ret if (input.funcname == "comparePasswords"): ret = database.comparePasswords(input.email, input.password) return ret if (input.funcname == "addTransaction"): ret = database.addTransaction(input.sender, input.receiver, input.category, input.memo, input.amount, input.date) if (input.funcname == "getTransaction"): ret = database.getTransacation(input.tid) print ret if (input.funcname == "getTransactions"): ret = database.getTransactions(input.uid) if (input.funcname == "getGroup"): ret = database.getGroup(input.gid) if (input.funcname == "getPassword"): ret = database.getPassword(input.email) return
def createUser(): if web.SESSION.get('level', -1) < 200: log(0, lang['ERR_ACCESS_DENIED']) return username = web.POST.get('username') fullname = web.POST.get('fullname') password = web.POST.get('password1') passchk = web.POST.get('password2') level = web.POST.get('level', 0) if not username: log(0, lang['ERR_NO_FULLNAME']) return if not username: log(0, lang['ERR_NO_USERNAME']) return if password != passchk: log(0, lang['ERR_PASSWORD_MISMATCH']) return rc = database.createUser(username, fullname, level, password) if rc: web.redirect(web.POST.get('next', ''), 3, 'MSG_USER_CREATED') else: log(0, 'ERR_USER_NOT_CREATED')
def inviteUsers(responders): for netid in responders: if db.getUser(netid) == None: db.createUser(netid)
def createUsername(): return createUser()
## Sample database import database as db # Testing # Sample time strings sample1 = "[{'date': '04-22-2017', 'time': '9:00am'}, {'date': '04-23-2017', 'time': '10:00am'}, {'date': '04-24-2017', 'time': '11:30am'}, {'date': '04-25-2017', 'time': '12:30pm'}, {'date': '04-26-2017', 'time': '1:00pm'}, {'date': '04-23-2017', 'time': '9:00am'}, {'date': '04-22-2017', 'time': '10:00am'}, {'date': '04-22-2017', 'time': '11:30am'}, {'date': '04-23-2017', 'time': '11:30am'}, {'date': '04-22-2017', 'time': '12:30pm'}, {'date': '04-23-2017', 'time': '12:30pm'}, {'date': '04-24-2017', 'time': '12:30pm'}, {'date': '04-22-2017', 'time': '1:00pm'}, {'date': '04-23-2017', 'time': '1:00pm'}, {'date': '04-24-2017', 'time': '1:00pm'}, {'date': '04-25-2017', 'time': '1:00pm'}]" sample2 = "[{'date': '04-22-2017', 'time': '9:00am'}, {'date': '04-23-2017', 'time': '10:00am'}, {'date': '04-24-2017', 'time': '11:30am'}, {'date': '04-25-2017', 'time': '12:30pm'}, {'date': '04-26-2017', 'time': '1:00pm'}]" sample3 = "[{'date': '04-23-2017', 'time': '10:00am'}, {'date': '04-24-2017', 'time': '11:30am'}, {'date': '04-23-2017', 'time': '11:30am'}, {'date': '04-23-2017', 'time': '12:30pm'}, {'date': '04-24-2017', 'time': '12:30pm'}, {'date': '04-23-2017', 'time': '1:00pm'}, {'date': '04-24-2017', 'time': '1:00pm'}]" sample4 = "[{'date': '04-22-2017', 'time': '9:00am'}, {'date': '04-22-2017', 'time': '10:00am'}, {'date': '04-22-2017', 'time': '11:30am'}, {'date': '04-22-2017', 'time': '12:30pm'}, {'date': '04-22-2017', 'time': '1:00pm'}, {'date': '04-23-2017', 'time': '9:00am'}, {'date': '04-23-2017', 'time': '10:00am'}, {'date': '04-23-2017', 'time': '11:30am'}, {'date': '04-23-2017', 'time': '12:30pm'}, {'date': '04-23-2017', 'time': '1:00pm'}]" sample5 = "[{'date': '04-22-2017', 'time': '9:00am'}, {'date': '04-22-2017', 'time': '10:00am'}, {'date': '04-22-2017', 'time': '11:30am'}, {'date': '04-22-2017', 'time': '12:30pm'}]" sample6 = "[{'date': '04-22-2017', 'time': '10:00am'}, {'date': '04-22-2017', 'time': '11:30am'}, {'date': '04-23-2017', 'time': '1:00pm'}]" ## Create users ########################################### db.createUser('hsolis', 'Hector', 'Solis') db.createUser('gwan', 'Gerry') db.createUser('bargotta') hector = db.getUser('hsolis') gerry = db.getUser('gwan') aaron = db.getUser('bargotta') ## Create meetings ######################################## db.createMeeting('test1', hector.uid, "[2, 3]", "04-21-2017") db.createMeeting('test2', hector.uid, "[2, 3]", "04-21-2017") db.createMeeting('test3', gerry.uid, "[1, 3]", "04-21-2017") db.createMeeting('test4', gerry.uid, "[1, 3]", "04-21-2017") db.createMeeting('test5', aaron.uid, "[2]", "04-21-2017")
# Testing # Sample time strings pref1 = "[{'day': 'Sat', 'time': '9:00am'}, {'day': 'Sun', 'time': '10:30am'}]" pref2 = "[{'day': 'Fri', 'time': '8:00pm'}, {'day': 'Mon', 'time': '10:30am'}]" sample1 = "[{'date': '04-29-17', 'time': '5:00pm'}, {'date': '04-30-17', 'time': '5:30pm'}]" sample2 = "[{'date': '04-12-17', 'time': '4:30pm'}]" sample3 = "[{'date': '04-29-17', 'time': '4:30pm'}, {'date': '04-19-17', 'time': '8:00am'}, {'date': '04-29-17', 'time': '6:00pm'}]" sample4 = "[{'date': '04-30-17', 'time': '8:00pm'}]" sample5 = "[{'date': '04-12-17', 'time': '2:00pm'}]" sample6 = "[{'date': '04-19-17', 'time': '8:00am'}]" ## Create users and check that they were properly added ########################################### db.createUser('hsolis', 'Hector', 'Solis', pref1) db.createUser('gwan', 'Gerry') db.createUser('bargotta', unacceptableTimes=sample2) db.createUser('ksha', lastName='Sha', acceptableTimes=sample3) db.createUser('kl9', 'Katherine', 'Lee', pref1) hector = db.getUser('hsolis') gary = db.getUser('gwan') aaron = db.getUser('bargotta') kim = db.getUserFromId(4) katlee = db.getUserFromId(5) assert hector.uid == 1 and hector.firstName == 'Hector' and \ hector.lastName == 'Solis' and hector.preferredTimes == pref1 assert gary.uid == 2 and gary.firstName == 'Gerry' and \