def main(): user = input("username: "******"password: "******"用户名或密码错误!") else: print("进入后台管理页面!")
def main(): usr = input("username:"******"password:"******"登录失败!") else: print("登陆成功!进入后台管理界面..")
def registered():#注册 user = raw_input('username:'******'password:') if len(user.split()) == 0 or len(pwd.split()) == 0: print ("用户名或密码为空,请重新输入") return registered() else: admin = Admin() result = admin.regist(user,pwd) print "注册成功,请牢记用户名密码"
def main(): user = raw_input('username:'******'password:'******'用户名或者密码错误' else: print '登陆后台管理界面'
def get(self): page = self.get_argument('page', 1) rows = self.get_argument('rows', 20) start = (int(page) - 1) * int(rows) limit = rows user_list = User.gets(start, limit) total = User.get_count() response = {'total': total, 'rows': user_list} return self.write(date_encode(response))
def main(): user = input('username:'******'password:'******'user check result:',result) if not result: print('Wrong username or password') else: print('login success')
def main(): user = input('username:'******'password:'******'mimacuowu!') else: print('dengluchenggong!')
def get(self): page = self.get_argument('page', 1) rows = self.get_argument('rows', 20) start = (int(page) - 1) * int(rows) limit = rows user_list = User.gets(start, limit) total = User.get_count() response = { 'total': total, 'rows': user_list } return self.write(date_encode(response))
def sign_in(): print " 欢迎进入注册页面 " user = raw_input('username: ') password = raw_input("password: "******"注册成功............." print "请登录............" login() else: print "用户已存在,请输入有效的用户名" sign_in()
def post(self): username = self.get_argument('username', '') password = self.get_argument('password', '') self.set_header("Content-Type", "application/json") if not (username and password): ret = { 'error': 110, 'msg': self.error_message['110'], 'url': '/admin/index' } return self.write(json_encode(ret)) user = User.get_by_username(username) if not user: ret = {'error': 121, 'msg': self.error_message['121']} return self.write(json_encode(ret)) if user.get_password() != encrypt(password): ret = {'error': 122, 'msg': self.error_message['122']} return self.write(json_encode(ret)) self.set_secure_cookie("admin_user_id", str(user.user_id), expires_days=7) ret = {'error': 0, 'msg': '登录成功', 'url': '/admin/index'} return self.write(json_encode(ret))
def post(self): user_id = int(self.get_argument('id', 0)) username = self.get_argument('username', '') password = self.get_argument('password', '') email = self.get_argument('email', '') realname = self.get_argument('realname', '') role_id = int(self.get_argument('role_id', 0)) match = re.search(r'[\w.-]+@[\w.-]+', email) if not match: ret = {'code': 112, 'msg': self.error_message['112']} return self.write(json_encode(ret)) if not role_id: ret = {'code': 113, 'msg': self.error_message['113']} return self.write(json_encode(ret)) result = User.update(user_id, username, email, password, realname, role_id) if result: ret = {'code': 0, 'msg': '更新成功'} return self.write(json_encode(ret)) else: ret = {'code': 114, 'msg': self.error_message['114']} return self.write(json_encode(ret))
def get_current_user(self): user = None json_ = self.get_secure_cookie("admin") if json_: user = Admin.from_json(json_) return user
def create_default_objects(): ''' Creates a list of default users and accounts for testing purposes ''' # Create a default Admin user Admin(username="******", password="******", first_name="Jack").save() print("Default Admin Created") cust1 = Customer(username="******", password="******", first_name="John") cust1.save() print("Default Customer Created") Checking_Account(account_number="1", owner=cust1).save() print("Default Checking Account Created") Savings_Account(account_number="2", owner=cust1).save() print("Default Savings Account Created") cust2 = Customer(username="******", password="******", first_name="Clark") cust2.save() print("Default Customer2 Created") Savings_Account(account_number="3", owner=cust2).save() print("Default Savings Account Created") Brokerage_Account(account_number="4", owner=cust1).save() print("Default Brokerage Account Created")
def login(): print " 欢迎进入登录页面 " user = raw_input('username: ') password = raw_input("password: "******"用户名不存在" else: res = admin.CheckValidata(user, password) if not res: print "密码错误" login() else: uid = admin.Get_Uid(user)[0] client.connect_robot(uid)
def identity(payload): uuid = payload['identity'] ret = User.find_by_uuid(uuid) if ret.check() is False: ret = Admin.find_by_uuid(uuid) if ret.check() is False: return return ret.data
def enable(): if request.method == 'GET': return render_template('admin/activate.html', host=app.config['DOMAIN']) elif request.method == 'POST': try: admin = Admin.objects( Q(login=request.form['login']) & Q(password=Admin.get_password(request.form['password'])) ).first() if not admin: raise Exception('Неверный логин или пароль администратора') activate_user(admin.name, request.form['username'], int(request.form['time'])) return dumps(dict(code=200)) except Exception as msg: return dumps(dict(code=400, message=str(msg)))
def login(self, username, password): # try logging as admin try: self.user = Admin.login(username, password) except Admin.DoesNotExist: # try logging as customer try: self.user = Customer.login(username, password) except Customer.DoesNotExist: raise LoginError("The user and password combination you tried is invalid.")
def post(self): password = self.get_argument('password', '') self.set_header("Content-Type", "application/json") user = User.get_by_uid(self.get_secure_cookie("admin_user_id")) if user.get_password() == encrypt(password): ret = {'code': 0} else: ret = {'code': 1} return self.write(json_encode(ret))
def post(self): username = self.get_argument('username', '') self.set_header("Content-Type", "application/json") user = User.get_by_username(username) if not user: ret = {'code': 0} else: ret = {'code': 1} return self.write(json_encode(ret))
def authenticate(username, password, user_type): ret = None if user_type: ret = Admin.find_by_username(username) else: ret = User.find_by_username(username) if ret.check() is False: return if ret.data and ret.data.confirm_password(password): if user_type == ret.data.login_type: return ret.data
def post(self): email = self.get_argument('email', '') self.set_header("Content-Type", "application/json") user = User.get_by_email(email) if not user: ret = {'code': 0} else: ret = {'code': 1} return self.write(json_encode(ret))
def make_admin(username, password): __tablename__ = 'user' password_gen = generate_password_hash(password, method='sha256') with app.app_context(): add_admin = Admin(username=username, password=password_gen) db.session.add(add_admin) db.session.commit() db.session.close()
def post(self): req_json = json.dumps(request.get_json()) load_data, errors = BasicSchema().loads(req_json) if errors: return RetStatus(False, "parse request data failed.").dumps_json() ret = Admin.find_by_username(load_data['username']) if ret.check() is False: return RetStatus(False, "check user's availability failed.").dumps_json() elif ret.data is None: return RetStatus(False, "username had be used.").dumps_json() user = Admin(uuid=uuid.uuid1(), username=load_data['username'], password=load_data['password'], login_type=load_data['login_type']) add_ret = Admin.ADD(user) if add_ret.check() is False: return add_ret.dumps_json() return RetStatus(True, "register success.", data=user.uuid).dumps_json()
def adminCheck(): req = request.json print(req) openid = req.get('openid') pwd = req.get('pwd') if (pwd == 'AP2021'): newAdmin = Admin(openid) db.session.add(newAdmin) db.session.commit() return jsonify({'res': True}) return jsonify({'res': False})
def handle(self): request = self.request request.send("hello. Can I help you.....") flag = True admin = Admin() while flag: data = request.recv(1024) uid = data.split(":")[0] content = data.split(":")[1] print uid, content if content == "exit": flag = False value = admin.Get_Value(content) if not value: prompt = "数据库中没有你需要的答案" admin.Insert_key_value(uid, content, prompt) request.send(prompt) else: admin.Insert_key_value(uid, content, value[0]) request.send(value[0]) request.close()
def post(self): msg = '' success = False o = self.json admin = Admin.admin_login(o.user_name, o.password) if admin: self.set_secure_cookie("admin", json.dumps(dict(admin))) msg = '' success = True else: msg = "登录错误" self.finish(dict(success=success, msg=msg))
def login(self): ''' Request user credentials and logs them in as either an Admin or Customer ''' self.user = None while self.user is None: username = input("Username: "******"Invalid Login")
def main_dashboard(self, db, user): """ Main Dashboard :param db: :param user: :return: """ print( 'Welcome to Cab Booking Service!!\nLogin as :\n1 : Admin\n2 : Employee\n3 : Exit' ) while True: try: n = int(input('Enter your choice : ')) break except: print('\n***Only numbers is allowed***\n') if n == 1: admin = Admin(db, user) admin.login() elif n == 2: employee = Employee(db, user) employee.login() else: sys.exit(1)
def post(self): password = self.get_argument('new_password', '') self.set_header("Content-Type", "application/json") if not password: ret = {'code': 210, 'msg': self.error_message['210'], 'url': self.url} return self.write(json_encode(ret)) user = User.get_by_uid(self.get_secure_cookie("admin_user_id")) if not user: ret = {'code': 211, 'msg': self.error_message['211']} return self.write(json_encode(ret)) user.update_password(password) ret = {'code': 0, 'msg': '更新成功', 'url': self.url} return self.write(json_encode(ret))
def init(): from app import db db.drop_all() from model.admin import Admin from model.airline import Airline from model.flight import Flight from model.client import Client from model.ticket import Ticket db.create_all() admin = Admin(username='******', password='******') airline1 = Airline(title='Aeroflot') airline2 = Airline(title='Ural airlines') airline3 = Airline(title='S7 airlines') db.session.add(admin) db.session.add(airline1) db.session.add(airline2) db.session.add(airline2) db.session.commit()
def add_admin(): os.system('cls') print(f"{'Add admin baru':^50}") print("=" * 50) admins = load_admins() admin_name = input_string("Nama lengkap: ") admin_age = input_int("Umur: ") while True: admin_id = input_string("Id: ") if admin_id not in [admin.id for admin in admins]: break else: print("Id telah digunakan") admin_password = input_password("Password: "******"Admin berhasil ditambahkan") os.system('pause')
def post(self): realname = self.get_argument('realname', '') email = self.get_argument('email', '') self.set_header("Content-Type", "application/json") if not (realname and email): ret = {'code': 110, 'msg': self.error_message['110'], 'url': self.url} return self.write(json_encode(ret)) user = User.get_by_uid(self.get_secure_cookie("admin_user_id")) if not user: ret = {'code': 111, 'msg': self.error_message['111']} return self.write(json_encode(ret)) user.update('', email, realname) ret = {'code': 0, 'msg': '更新成功', 'url': self.url} return self.write(json_encode(ret))
def post(self): password = self.get_argument('new_password', '') self.set_header("Content-Type", "application/json") if not password: ret = { 'code': 210, 'msg': self.error_message['210'], 'url': self.url } return self.write(json_encode(ret)) user = User.get_by_uid(self.get_secure_cookie("admin_user_id")) if not user: ret = {'code': 211, 'msg': self.error_message['211']} return self.write(json_encode(ret)) user.update_password(password) ret = {'code': 0, 'msg': '更新成功', 'url': self.url} return self.write(json_encode(ret))
def post(self): username = self.get_argument('username', '') password = self.get_argument('password', '') self.set_header("Content-Type", "application/json") if not (username and password): ret = {'error': 110, 'msg': self.error_message['110'], 'url': '/admin/index'} return self.write(json_encode(ret)) user = User.get_by_username(username) if not user: ret = {'error': 121, 'msg': self.error_message['121']} return self.write(json_encode(ret)) if user.get_password() != encrypt(password): ret = {'error': 122, 'msg': self.error_message['122']} return self.write(json_encode(ret)) self.set_secure_cookie("admin_user_id", str(user.user_id), expires_days=7) ret = {'error': 0, 'msg': '登录成功', 'url': '/admin/index'} return self.write(json_encode(ret))
def post(self): realname = self.get_argument('realname', '') email = self.get_argument('email', '') self.set_header("Content-Type", "application/json") if not (realname and email): ret = { 'code': 110, 'msg': self.error_message['110'], 'url': self.url } return self.write(json_encode(ret)) user = User.get_by_uid(self.get_secure_cookie("admin_user_id")) if not user: ret = {'code': 111, 'msg': self.error_message['111']} return self.write(json_encode(ret)) user.update('', email, realname) ret = {'code': 0, 'msg': '更新成功', 'url': self.url} return self.write(json_encode(ret))
def post(self): Aid = self.getData("Aid") post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key)[0] response = None result_data = {} userName = self.getData('userName') passWord = self.getData('passWord') level = self.getData('level') nick = self.getData('nick') type = self.getData('type') response = self.IsSuperadmin(post_data) if response != None: respon_json = json.dumps(response) self.write(respon_json) return if userName !="" and passWord !="": passWord = hashlib.md5(passWord).hexdigest() suAdmin = Dal_Admin().getValueByAttr('userName', userName) if len(suAdmin) == 0: add_data = Admin(id=None, userName=userName, passWord=passWord, nickname=nick, admin=level, token=None, type=type) newAdmin = Dal_Admin().addAdmin(add_data) response = { 'errorcode': config_error['success'], } # 更新操作 operate = configs_default['adminOperate']['RegSubadmin'] Dal_Admin().addOperate(Aid, operate) else: response = { 'errorcode': config_error['userrepeated'], } respon_json = json.dumps(response) self.write(respon_json)
from model.admin import Admin, Moderator from model.session import Session from model.money import Money, Wallet,GOLD,SILVER,COPPER if __name__=="__main__": player = Player(nickname='Arseni', email='*****@*****.**', password='******') print("{}Information about the player.\n".format(player)) player.save_to_db() print("{}Player was inserted to db.\n".format(player)) admin = Admin(nickname='admin_arseni', email='*****@*****.**', password='******') print("{}Information about the player.\n".format(admin)) admin.save_to_db() print("{}Admin was inserted to db.\n".format(admin)) moderator = Moderator(nickname='moderator_arseni', email='*****@*****.**', password='******') print("{}Information about the player.\n".format(moderator)) moderator.save_to_db() print("{}Moderator was inserted to db.\n".format(moderator)) player_info = Player() player_info.load_from_db("*****@*****.**") print("{}Player was loaded from db.\n".format(player_info))
def main(): user = raw_input('username:'******'password:') admin = Admin() result = admin.checkValidata(user,pwd) print result
print("Invalid selection, please type either 1,2 or 3") except SyntaxError: print '\n####################################\n' \ 'You have typed nothing.\n' \ 'Try again or type 3 to exit...\n' ######################################################################################################################## gold = Money(code=GOLD, amount=9999) silver = Money(code=SILVER, amount=99999) copper = Money(code=COPPER, amount=999999) admin_wallet = Wallet(gold, silver, copper) Alex = Admin(nickname='Alex', email='*****@*****.**', password='******', wallet=admin_wallet) Alex2 = Moderator(nickname='Alex2', email='*****@*****.**', password='******', wallet=admin_wallet) print(u"\nAdministrator:" u"\n#################################################\n" \ u"{}" u"\n#################################################\n".format(Alex)) Alex.save(open("admin_alex.txt", "w")) Alex.ban_player("users.txt", 'arseni2') print'\n' Alex.unban_player("users.txt", 'arseni2') # Alex.delete_player("arseni_player.txt") print(u"\nModerator:" u"\n#################################################\n" \
def get(self): user_id = int(self.get_argument('id', 0)) user = User.get(user_id) roles = AdminRole.gets() return self.render(self.url, info=user, roles=roles)