示例#1
0
def login():
    # global test_data
    if request.method == "POST":
        username = request.form['username']
        password = hashlib.md5(request.form['password'].encode()).hexdigest()
        captcha = request.form['captcha']
        if username and password and captcha == '.tie5Roanl':
            cursor = mysql.connection.cursor()
            result = cursor.execute("SELECT * FROM users WHERE username = %s",
                                    [username])
            if result > 0:
                data = cursor.fetchone()
                if password == data[2]:
                    time.sleep(1)
                    data = pd.read_csv('test_data.csv', header=None)
                    # print('mihir',data.head(5))
                    predicted_user = authenticate_user(data.head(1))
                    if predicted_user[0].lower() == username.lower():
                        flash('You are now logged in', 'success')
                    else:
                        flash('Hacker', 'danger')
                else:
                    flash('Your username and password does not match',
                          'danger')
    return render_template('login.html')
示例#2
0
async def login(form_data: OAuth2PasswordRequestForm = Depends()):
    user = authenticate_user(form_data.username, form_data.password)
    if user is None:
        LOGGER.debug("User authentication failed for %s", form_data.username)
        raise HTTPException(status_code=HTTPStatus.BAD_REQUEST,
                            detail="Username not found")
    access_token = create_access_token(username=user.username)
    return {"access_token": access_token, "token_type": "bearer"}
示例#3
0
文件: main.py 项目: progCloud/client
def main_func():
	fo = open(settings.secrets_file, "rw+")
	email = fo.readline().rstrip()
	password = fo.readline().rstrip()
	watch_dir = fo.readline().rstrip()
	fo.close()
	if(authentication.authenticate_user(email,password)=='1'):
		print 'User Authenticated! Watching Directory'
		loop.watch_directory(watch_dir)
	else:
		getuserinput.enter()
		print 'Failed To Authenticate User'
示例#4
0
async def login_for_access_token(
        form_data: OAuth2PasswordRequestForm = Depends(),
        db: Session = Depends(get_db)):
    user = authentication.authenticate_user(db, form_data.username,
                                            form_data.password)
    if not user:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Incorrect username or password",
            headers={"WWW-Authenticate": "Bearer"},
        )
    access_token_expires = timedelta(
        minutes=authentication.ACCESS_TOKEN_EXPIRE_MINUTES)
    scopes = authentication.get_scopes_from_db(user)
    access_token = authentication.create_access_token(
        data={
            "sub": user.username,
            "scopes": scopes
        },
        expires_delta=access_token_expires)
    logging.info(user)
    return {"access_token": access_token, "token_type": "bearer", "user": user}
示例#5
0
文件: poems.py 项目: rje4242/poemtube
 def GET(self, urlid):
     user = authenticate_user(self.db)
     return do_json(json_poems.GET, self.db, clean_id(urlid), user,
                    web.input())
示例#6
0
                         borderwidth=1,
                         font=('times', '8', 'normal'))
        label.pack(ipadx=1)

    def close(self, event=None):
        if self.tw:
            self.tw.destroy()


if __name__ == '__main__':
    # file that contains the access token used for making authenticated calls
    token_file = os.path.join(os.path.dirname(__file__), '.token')

    # read the token file
    if os.path.exists(token_file):
        with open(token_file) as f:
            access_token = f.read().strip()

    # if it's not there, get a new one and save it
    else:
        access_token = authentication.authenticate_user()
        with open(token_file, 'w') as f:
            f.write(access_token)

    root = tk.Tk()
    app = StreamPicker(root, access_token)
    root.title('Stream Picker')
    root.configure(background='gray15')
    root.geometry('+210+150')
    root.mainloop()
示例#7
0
 def GET( self, urlid ):
     user = authenticate_user( self.db )
     return do_json(
         json_poems.GET, self.db, clean_id( urlid ), user, web.input() )
示例#8
0
 def GET( self ):
     user = authenticate_user( self.db )
     web.header( 'Content-Type', 'application/json' )
     return do_json( json_whoami.GET, user )
示例#9
0
 def GET(self):
     user = authenticate_user(self.db)
     web.header('Content-Type', 'application/json')
     return do_json(json_whoami.GET, user)