예제 #1
0
 def __init__(self, name='환자', email=None, passwd=None, makeSha=False):
     self.email = email
     if makeSha:
         self.password = func.sha2(passwd, 256)
     else:
         self.password = passwd
     self.name = name
예제 #2
0
def update_user(user_id):
    '''
        :: update selected user.
    '''

    jsonData = request.get_json()
    data = jsonData['data']
    data['passwd'] = func.sha2(data['passwd'], 256)

    try:
        User.query.filter_by(id=user_id).update(data,
                                                synchronize_session=False)
        db_session.commit()
        return jsonify(
            {"result": {
                "code": 200,
                "message": "user successfully updated."
            }})
    except SQLAlchemyError as sqlerr:
        db_session.rollback()
        return jsonify(
            {"result": {
                "code": 500,
                "message": "user is existed."
            }})
예제 #3
0
def login_post():
    login_data = request.json
    email = login_data['email']
    passwd = login_data['password']
    rt_data = {}
    # u = Users.query.filter('email = :email and `password` = sha2(:passwd, 256)').params(email=email, passwd=passwd).first()
    # u = Users.query.filter(Users.email == email and Users.password == func.sha2(passwd, 256)).first()
    u = Users.query.filter(Users.email == email).filter(
        Users.password == func.sha2(passwd, 256)).first()
    print(">>>>>>", u)
    if u is not None:
        session['loginUser'] = {
            'userid': u.user_no,
            'name': u.nickname,
            'premium': u.premium
        }
        if session.get('next'):
            next = session.get('next')
            rt_data["user"] = u.nickname
            rt_data["res"] = "ok"
            rt_data["next"] = next
            del session['next']
            print("OOOOOOOOOKKKKKKKKKKKK")
            return jsonify(rt_data)
        rt_data["user"] = u.nickname
        rt_data["res"] = "ok"
        print(">>>>rt rt rtrt", rt_data)
        return jsonify(rt_data)
    else:
        return jsonify('error')
예제 #4
0
파일: models.py 프로젝트: srshin/hello
 def __init__(self, email=None, passwd=None, nickname='손님', makeSha=False):
     self.email = email
     if makeSha:
         self.passwd = func.sha2(passwd, 256)
     else:
         self.passwd = passwd
     self.nickname = nickname
예제 #5
0
파일: views.py 프로젝트: gouwon/LogForYou
def login():
    print("3333333333")
    email = request.form.get('email')
    passwd = request.form.get('passwd')
    table = request.form.get('table')
    utype = ""

    if table == 'patient':
        # u = Patient.query.filter('email = :email and password = sha2(:passwd, 256)').params(email=email, passwd=passwd).first()
        # u = Patient.query.filter(Patient.email == email, Patient.password == func.sha2(passwd, 256)).first()
        u = Patient.query.filter(Patient.email == "a@com",
                                 Patient.password == func.sha2("a",
                                                               256)).first()
        utype = False
    else:
        # u = Doctor.query.filter('email = :email and password = sha2(:passwd, 256)').params(email=email, passwd=passwd).first()
        u = Doctor.query.filter(Doctor.email == email,
                                Doctor.password == func.sha2(passwd,
                                                             256)).first()
        utype = True

    if u is not None:
        print("313131313131")
        session['loginUser'] = {'userid': u.id, 'name': u.name, 'utype': utype}
        # session['next'] = '/main'
        # print(session)
        # if session.get('next'):
        #     next = session.get('next')
        #     print(">>>>>", next)
        #     del session['next']
        #     return redirect(next)
        if (utype == True):
            session['next'] = '/main'
            next = session.get('next')
            print(">>>>>", next)
            del session['next']
            return redirect(next)
        else:
            session['next'] = '/log'
            next = session.get('next')
            print(">>>>>", next)
            del session['next']
            return redirect(next)

    else:
        flash("해당 사용자가 없습니다!!")
        return redirect("/login")
예제 #6
0
 def __init__(self,
              username='******',
              userid='0',
              password='',
              make_sha=False):
     self.username = username
     self.userid = userid
     self.password = func.sha2(password, 256) if make_sha else password
     self.authority = 5
예제 #7
0
파일: models.py 프로젝트: dohyekim/PyWeb
    def __init__(self, passwd, email, username, makesha=False):

        if makesha:
            self.passwd = passwd
        else:
            self.passwd = func.sha2(passwd, 256)

        self.email = email
        self.username = username
예제 #8
0
def sendpwd():
    data = request.json
    print(data)
    u = Users.query.filter(Users.email == data['id']).filter(
        Users.password == func.sha2(data['pwd'], 256)).first()
    if u is not None:
        return jsonify("ok")
    else:
        print("NOPE")
        return jsonify("error")
예제 #9
0
 def __init__(self,
              first_name='gest',
              last_name='gest',
              email=None,
              password=None,
              created=None,
              makeSha=False):
     self.first_name = first_name
     self.last_name = last_name
     self.email = email
     if makeSha:
         self.password = func.sha2(password, 256)
     else:
         self.password = password
     self.created = created
예제 #10
0
    def __init__(self,
                 email,
                 password,
                 name,
                 phone_number,
                 nickname,
                 address,
                 makesha=False):

        if makesha:
            self.password = password
        else:
            self.password = func.sha2(password, 256)

        self.email = email
        self.phone_number = phone_number
        self.name = name
        self.nickname = nickname
        self.address = address
예제 #11
0
파일: auth.py 프로젝트: gouwon/flask_app
def login(next=None):    
    next = request.args.get('next') if request.args.get('next') is not None \
            else 'index'

    if request.method == 'POST':
        data = {
            'id' : request.form.get('id'),
            'pw' : func.sha2(request.form.get('password'), 256)
        }

        # user = User.query.filter(User.userid==data['id'], \
        #                          User.password==data['pw']).first()
        user = User.query.filter(User.userid=='*****@*****.**', \
                                User.password=='a').first()
        if(user is not None):
            session['loginUser'] = user._jsonify()
            res = jsonify(user._jsonify())
        return render_template('login.html', result="not found") \
                if (user is None) else redirect(url_for('bd.draw_board'))
    return render_template('login.html', next=next)
예제 #12
0
 def __eq__(self, other):
     local_pw = type_coerce(self.expr, CHAR)
     return local_pw == func.sha2(other, 256)
예제 #13
0
 def __setattr__(self, name, value):
     if name == 'password':
         value = func.sha2(value, 256)
     return super().__setattr__(name, value)
예제 #14
0
 def __eq__(self, other):
     # we coerce our own "expression" down to String,
     # so that invoking == doesn't cause an endless loop
     # back into __eq__() here
     local_pw = type_coerce(self.expr, String)
     return local_pw == func.sha2(other, 256)
예제 #15
0
 def bind_expression(self, bindvalue):
     return func.sha2(bindvalue, 256)
예제 #16
0
파일: models.py 프로젝트: gouwon/flask_app
 def __init__(self, email, passwd, nickname, make_sha=False):
     self.email = email
     self.nickname = nickname
     self.passwd = func.sha2(passwd, 256) if make_sha else passwd
예제 #17
0
 def bind_expression(self, bindvalue):
     return func.sha2(bindvalue, 256)
예제 #18
0
 def __call__(self, input_password):
     self.password = func.sha2(input_password, 236)