Пример #1
0
def user_register():
    email = input("Enter Email Id : ")
    password = input("Enter Password : "******"Enter Mobile No : ")
    role = input("Enter Role 'A' or 'U' : ")
    email_regex = '^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$'
    password_regex = '((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@*#$%]).{6,20})'

    amount = input("You need to deposit a base amount of 1000Rs to open account:")

    if role == 'a' or role == 'A':
        role = "A"
    elif role == 'u' or role == 'U':
        role = "U"
    else:
        role = "U"

    if int(amount) >= 1000:
        if re.match(email_regex, email) and re.match(password_regex, password):
            user_model_obj = UserModel()
            return user_model_obj.user_registration(email, password, mobile_no, role, int(amount))
        else:
            return "Either Email_Id or Password doesn't meet our reg_ex requirements."
    else:
        return "Sorry, we can't open you the account without base amount in the account while registering."
    def post(self):
        data = UserRegister.parser.parse_args()
        if UserModel.find_by_username(data['username']):
            return {
                "success": False,
                "message": "That Username already exists, please try another"
            }, 400
        connection = sqlite3.connect("./Models/data.db")

        user = UserModel(**data)
        user.save_to_db()

        return {"message": "User has been created successfully."}, 201
Пример #3
0
 def login(user_mobile):
     try:
         same_user = user_collection.find_one({UserModelVN.Phonenumber: user_mobile})
         if same_user:
             # todo : send code
             User.gen_code(user_mobile, str(same_user.inserted_id))
             return Tools.Result(True, "Code has been sent")
         else:
             new_user = UserModel(Phonenumber=user_mobile)
             new_user = user_collection.insert_one(new_user.dict())
             # Token ???
             # todo : send code
             User.gen_code(user_mobile, str(new_user.inserted_id))
             return Tools.Result(True, "Code has been sent")
     except Exception as ex:
         return Tools.Result(False, ex.args)
Пример #4
0
def authentication(username, password):
    user = UserModel.find_by_username(username)
    if user and safe_str_cmp(user.password, password):
        return user
Пример #5
0
def identity(payload):
    user_id = payload['identity']
    return UserModel.find_by_id(user_id)
Пример #6
0
def user_login():
    email = input("Enter Email Id : ")
    password = input("Enter Password : ")
    user_model_obj = UserModel()
    return user_model_obj.user_authentication(email, password)
Пример #7
0
    if cah.Auth(cusAccount, password):
        Log(u'客服 建权成功: {0}'.format(cah.AccessKey))
    if eah.Auth(expAccount, password):
        Log(u'专家 建权成功: {0}'.format(eah.AccessKey))
    countSucceed = 0
    schemeUnique = mah.MgrGetSchemeInfo(schemeName)['Unique']  # 获取套餐编码
    Log(u'读取EcgCareOnline平台用户列表')
    allText = File.ReadAllText(ecgCareOLPath + 'Users.json')
    jsonUsers = JSON.Deserialize(allText)
    totalUser = len(jsonUsers)
    Log(u'共需要迁移 {0} 个用户...'.format(totalUser))
    indexUser = 0
    for jsonUser in jsonUsers:
        indexUser += 1
        Log(u'正在迁移第 {0} 个用户, 共 {1} 个用户需要迁移'.format(indexUser, totalUser))
        user = JSON.DictToInst(jsonUser, UserModel())
        if 0 == len(user.userAddr):
            Log(u'!!!医生地址不得为空! 已置为缺省值.')
            user.userAddr = DefaultUserAddr
        if u'已作废' == user.userName:
            Log(u'!!!已作废 记录, 跳过, {0}'.format(user.loginName))
            continue
        if u'作废账号' == user.userName:
            Log(u'!!!已作废 记录, 跳过, {0}'.format(user.loginName))
            continue
        if u'作废' == user.userName:
            Log(u'!!!已作废 记录, 跳过, {0}'.format(user.loginName))
            continue

        Log(u'设置系统时间,统一指定医生注册时间')
        Time.setSystemTime('2015-06-30 07:00:00')
Пример #8
0
 def __init__(self):
     self.__user_model = UserModel()
     self.__center_model = CenterModel()
Пример #9
0
class UserController:
    def __init__(self):
        self.__user_model = UserModel()
        self.__center_model = CenterModel()

    """
    *   @brief Call a model method to consult to the bd to know is the name and password given are registered
    *   @param id_student which is the id given to try to get logged
    *   @param password which is the password given to try to get logged
    *   @pre the socket connection has to been successful
    *   @return returns if the user is correct and exists
    """

    def exist_user(self, name, password):
        data = self.__user_model.exist_user(name, password)
        return data

    """
    *   @brief Call a model method to set to a specific student the state given
    *   @param id_student which is the id of the student we want to change his state
    *   @param state which is the new state of the user
    *   @pre the student has to been registered
    *   @post the student state will be changed
    """

    def set_user_state(self, id_student, state):
        self.__user_model.set_user_state(id_student, state)

    """
    *   @brief Call a model method to consult to db for the students in the same center that are connected
    *   @param id_student which is the id of the student we want to know his centre to know the other students
    *   @pre a center and a student of this center have been registed
    *   @return returns all the students in the same centre of the student given
    """

    def get_users_in_same_centre(self, id_student):
        students_in_same_center = self.__user_model.get_users_in_same_center(
            id_student)
        return students_in_same_center

    """
    *   @brief Get all the users of a center
    *   @param id_center which is the id of the center we want to know the students
    *   @pre an admin has been logged successfully
    *   @return an array with all the students of the center
    """

    def get_all_users_by_id_center(self, id_center):
        return self.__user_model.get_users_by_id_center(id_center)

    """
    *   @brief Get all the info of a user by his id
    *   @param id_user which is the id of the user we want the info
    *   @pre an admin has logged successfully
    *   @return all the info of the selected user
    """

    def get_user_by_id(self, id_user):
        return self.__user_model.get_user_by_id(id_user)

    """
    *   @brief Delete a student by his id
    *   @param id_user which is the id of the student we want to delete
    *   @pre an admin has logged successfully
    *   @post the selected user will be deleted 
    """

    def delete_user_by_id(self, id_user):
        self.__user_model.delete_user_by_id(id_user)

    """
    *   @brief Updates a student of a center.
    *   @param id_user which is the dni of the student that will be updated
    *   @param name which is the name that will be set to the student
    *   @param surname which is the surname that will be set to the student
    *   @param lastname which is the lastname that will be set to the student
    *   @param password which is the password that will be set to the student
    *   @param active which is the state that will be set to the student (if can log or not)
    *   @pre an admin has logged successfully
    *   @post a new student will be updated
    """

    def update_user_by_id(self, id_user, name, surname, lastname, password,
                          active):
        self.__user_model.update_user_by_id(id_user, name, surname, lastname,
                                            password, active)

    """
    *   @brief Adds a new user to the center that we get with the id.
    *   @param id_center is the center in which the user will be added
    *   @param id_admin which is the dni of the admin
    *   @param id_user which is the dni of the student that will be added
    *   @param name which is the name of the student
    *   @param surname which is the surname of the student
    *   @param lastname which is the lastname of the student
    *   @param password which is the password of the student
    *   @param active which is the state of the student (if can log or not)
    *   @pre an admin has logged successfully
    *   @post a new student will be added
    """

    def add_user(self, id_admin, id_user, name, surname, lastname, password,
                 active):
        id_center = self.__center_model.get_center_by_id_admin(id_admin)
        self.__user_model.add_user(id_center, id_admin, id_user, name, surname,
                                   lastname, password, active)
Пример #10
0
 def post(self):
     data = request.get_json()
     user = UserModel()
     return user.register_user(data['email'], data['password'])