transfer login function into js-file