Ejemplo n.º 1
0
 def admin_loginChecks(self):
     try:
         number = self.number.get()
         if number == "":
             showinfo(title="错误", message='请输入账号!')
         else:
             a = cxk(number)
             if (a <= 150):  #若差度在100内,可通过验证
                 self.page.destroy()
                 self.lab3.pack_forget()
                 AdminPage(self.root)
             elif (a == 200.0):
                 showinfo(title='错误', message='无该人脸信息,请先进行人脸注册!')
             else:
                 showinfo(title='错误', message="没有通过验证! 误差值为:%4.2f" % a)
     except:
         showinfo(title='错误', message='输入错误,请重新输入!')
Ejemplo n.º 2
0
def login(request, master):
    """
    Login functionality and role wise page calling done here 
    """
    sql = "SELECT * FROM user WHERE email_id = %(email_id)s AND password = %(password)s"

    cursor.execute(sql, request)
    answer = cursor.fetchone()

    #print(answer)

    if answer != None:
        if answer[2] != None:

            data = {
                "u_id": answer[0],
                "details": answer[1],
                "email_id": answer[5],
                "password": answer[5],
                "class": answer[3],
                "role_id": answer[2],
            }
            #print(data["details"][0])
            if data['role_id'] == 0:
                import Student
                Student.Student(master, data)
            elif data['role_id'] == 1:
                import Teacher
                Teacher.Teacher(master, data)
            elif data['role_id'] == 2:
                import ClassTeacher
                ClassTeacher.ClassTeacher(master, data)
            elif data["role_id"] == 3:
                import AdminPage
                AdminPage.Admin(master, data)
        else:
            import MainPage
            import tkinter.messagebox as tm
            tm.showerror("Role Unassigned", "Ask the admin to assign a role")
            MainPage.MainPage(master).login_page(1)
    else:
        import MainPage
        import tkinter.messagebox as tm
        tm.showerror("Invalid User", "Incorrect email or password!")
        MainPage.MainPage(master).login_page(1)
Ejemplo n.º 3
0
def login():
    print('Enter Your UserName')
    name = input()
    users = session.query(Admin)
    matchName = users.filter(Admin.username == name).first()
    if matchName:
        password = getpass('Password:'******'cls')
            print('Welcome To Admin Panel')
            AdminPage()
        else:
            system('cls')
            print("Wrong Username Or Password......")
            login()
    else:
        system('cls')
        print('Enter A Valid User Name')
        login()
Ejemplo n.º 4
0
 def admin_loginCheck(self, *event):
     global numbers
     '''
     管理员登录
     1:获取管理员账号与密码
     2:将获取到的账号与密码与数据库文件配对,配对成功返回值为正确,否则为错误
     3:将返回值判断,正确则登录界面清除,登录界面图片清除,进入管理员界面
     异常捕获:未填写账号或者密码
     '''
     try:
         Admin_number = self.number.get()
         Admin_pw = self.pw.get()
         if Admin_number == "1" and Admin_pw == "1":
             self.page.destroy()
             self.lab3.pack_forget()
             AdminPage(self.root)
         else:
             showinfo(title='错误', message='账号或密码错误!')
     except:
         showinfo(title='错误', message='输入错误,请重新输入!')
Ejemplo n.º 5
0
 def admin_loginCheck(self):
     '''
     管理员登录
     1:获取管理员账号与密码
     2:将获取到的账号与密码与数据库文件配对,配对成功返回值为正确,否则为错误
     3:将返回值判断,正确则登录界面清除,登录界面图片清除,进入管理员界面
     异常捕获:未填写账号或者密码
     '''
     try:
         Admin_id = self.user_id.get()
         #print(Admin_id)
         Admin_pw = self.user_pw.get()
         #print(Admin_pw)
         pd = admin_Select_id_pw(Admin_id, Admin_pw)
         if pd:
             self.page.destroy()
             self.lab3.pack_forget()
             AdminPage(self.root)
         else:
             showinfo(title='错误', message='账号或密码错误!')
     except:
         showinfo(title='错误', message='输入错误,请重新输入!')
Ejemplo n.º 6
0
    def __loginAction(self, event):
        """
        This method is called when the "Login" button is pressed
        It checks the administrator credentials
        """

        try:
            username = int(self.userNameEntry.get())
            mycursor = self.dbConnection.cursor()
            query1 = "select member_id from family"
            variable = (username, )
            mycursor.execute(query1)
            username_list = mycursor.fetchall()
            final_username_list = []
            for i in range(len(username_list)):
                final_username_list.append(username_list[i][0])
            if username not in final_username_list:
                messagebox.showerror("Error",
                                     "Entered member id is not registered.")

            else:
                password = self.passwordEntry.get()
                mycursor = self.dbConnection.cursor()
                query = "select password from family where member_id= %s"
                mycursor.execute(query, variable)
                password_from_db = mycursor.fetchone()[0]
                self.current_login = username
                if password == password_from_db:
                    AdminPage(self.parent, self.color, self.font,
                              self.dbConnection, self.width,
                              self.current_login)
                else:
                    messagebox.showerror(
                        "Error",
                        "The member id and password that you entered did not match our "
                        "records. "
                        "Please double-check and try again.")
        except Exception as e:
            messagebox.showerror(e)
Ejemplo n.º 7
0
    def __loginAction(self, event):
        '''
        This method is called when the "Login" button is pressed
        It checks if the administrator credentials are used or if
        the user that tries to connect exists in the database.
        '''

        username = self.userNameEntry.get()
        password = self.passwordEntry.get()

        if username == self.adminCredentials[0]:
            if password == self.adminCredentials[1]:
                AdminPage.AdminPage(self.parent, self.color, self.font,
                                    self.dbConnection)
            else:
                self.__incorectUP()
        else:
            cursor = self.dbConnection.cursor()

            args = (username, None, None, None, None)
            result = cursor.callproc('log_in', args)
            cursor.close()

            if result[1] is None:
                self.__incorectUP()
            elif password != result[4]:
                self.__incorectUP()
            else:
                print(result)
                userInfo = {
                    'userName': result[0],
                    'firstName': result[1],
                    'familyName': result[2],
                    'email': result[3]
                }
                print(userInfo)
                UserPage.UserPage(self.parent, self.color, self.font,
                                  self.dbConnection, userInfo)