def register(self): # validate fields self.email = self.register_ui.email.text() self.password = self.register_ui.password.text() self.password_repeat = self.register_ui.password_2.text() self.tools = Tools() success = False if self.email != "" and self.password != "" and self.password_repeat != "": if self.password == self.password_repeat: if self.tools.check_email(self.email): # take login action try: self.storj_client = \ storj.Client(None, '').user_create( str(self.email).strip(), str(self.password).strip()) success = True except storj.exception.StorjBridgeApiError as e: j = json.loads(str(e)) if j.get('error', None) == 'Email is already registered': QtGui.QMessageBox.about( self, 'Warning', 'User with this e-mail is \ already registered! Please \ login or try a different \ e-mail!') else: QtGui.QMessageBox.about(self, 'Unhandled exception', 'Exception: %s' % e) else: QtGui.QMessageBox.about( self, 'Warning', 'Your e-mail seems to be invalid! Please check e-mail and try again') else: QtGui.QMessageBox.about(self, 'Warning', 'Given passwords are different! Please check and try again!') else: QtGui.QMessageBox.about(self, 'Warning', 'Please fill out all fields!') if success: msgBox = QtGui.QMessageBox( QtGui.QMessageBox.Information, 'Success', 'Successfully registered in Storj Distributed Storage Network! ' 'Now, you must verify your email by' 'clicking the link that has been sent to you. ' 'Then you can login', QtGui.QMessageBox.Ok) self.__logger.debug('New user registered') self.__logger.debug('Email: %s', self.email) self.__logger.debug('Password: %s', self.password) result = msgBox.exec_() if result == QtGui.QMessageBox.Ok: self.login_window = LoginUI(self) self.login_window.show() self.close()
def __init__(self): account_manager = AccountManager() self.password = None if account_manager.if_logged_in(): self.password = account_manager.get_user_password() self.email = account_manager.get_user_email() # initialize Storj self.storj_client = storj.Client(email=self.email, password=self.password) logger.debug("Login from credentials xml file") logger.debug("testlogin, StorjEngine")
def __init__(self): self.account_manager = AccountManager() self.password = None if self.account_manager.if_logged_in(): self.password = self.account_manager.get_user_password() self.email = self.account_manager.get_user_email() # initialize Storj self.storj_client = storj.Client( email=self.email, password=self.password, do_hashing=False) self.__logger.debug('Login from credentials xml file') self.__logger.debug('testlogin, StorjEngine')
def register(self): # validate fields self.email = self.register_ui.email.text() self.password = self.register_ui.password.text() self.password_repeat = self.register_ui.password_2.text() self.tools = Tools() success = False if self.email != "" and self.password != "" and self.password_repeat != "": if self.password == self.password_repeat: if (self.tools.check_email(self.email)): # take login action try: self.storj_client = storj.Client(None, "").user_create(str(self.email).strip(), str(self.password).strip()) success = True except storj.exception.StorjBridgeApiError as e: j = json.loads(str(e)) if j.get("error", None) == "Email is already registered": QtGui.QMessageBox.about(self, "Warning", "User with this e-mail is \ already registered! Please \ login or try a different \ e-mail!") else: QtGui.QMessageBox.about(self, "Unhandled exception", "Exception: " + str(e)) else: QtGui.QMessageBox.about(self, "Warning", "Your e-mail seems to be invalid! Please chech e-mail and try again") else: QtGui.QMessageBox.about(self, "Warning", "Given passwords are different! Please check and try again!") else: QtGui.QMessageBox.about(self, "Warning", "Please fill out all fields!") if success: msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Success", "Successfully registered in Storj Distributed Storage Network! " "Now, you must verify your email by" "clicking the link that has been sent to you. " "Then you can login", QtGui.QMessageBox.Ok) logger.debug("New user registrated") logger.debug("Email: " + self.email) logger.debug("Password: " + self.password) result = msgBox.exec_() if result == QtGui.QMessageBox.Ok: self.login_window = LoginUI(self) self.login_window.show() self.close()
def __init__(self): self.conf_manager = Configuration() self.account_manager = AccountManager() self.password = None if self.account_manager.if_logged_in(): self.password = self.account_manager.get_user_password() self.email = self.account_manager.get_user_email() # initialize Storj max_bridge_request_timeout = self.conf_manager.get_max_bridge_request_timeout() bridge_api_url = self.conf_manager.get_bridge_api_url() self.storj_client = storj.Client(email=self.email, password=self.password, do_hashing=False, timeout=max_bridge_request_timeout, storj_bridge=bridge_api_url) logger.debug('Login from credentials xml file') logger.debug('testlogin, StorjEngine')
def login(self): # Take login action self.email = str(self.login_ui.email.text()).strip() self.password = str(self.login_ui.password.text()).strip() self.bridge_api_url = str( self.login_ui.bridge_url.text()).strip() # get bridge api url if self.bridge_api_url == "": self.bridge_api_url = DEFAULT_BRIDGE_API_URL self.storj_client = storj.Client(email=self.email, password=self.password) success = False # Take login action - check credentials by listing keys :D try: self.storj_client.key_list() success = True except storj.exception.StorjBridgeApiError as e: j = json.loads(str(e)) self.__logger.debug(j) if j[0]['error'] == 'Invalid email or password': QtGui.QMessageBox.about( self, 'Warning', 'Invalid email or password - access denied. ' 'Please check your credentials and try again!') else: QtGui.QMessageBox.about(self, 'Unhandled exception', 'Exception: %s' % e) if success: # Init account manager self.account_manager = AccountManager(self.email, self.password) # Save login credentials and state self.account_manager.save_account_credentials() msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, 'Success', 'Successfully logged in!', QtGui.QMessageBox.Ok) result = msgBox.exec_() if result == QtGui.QMessageBox.Ok: self.__logger.info('User {} succesfully logged in'.format( self.email)) self.main_ui_window = MainUI(self) self.main_ui_window.show() self.close()
def login(self): # take login action self.email = str(self.login_ui.email.text()).strip() # get mail self.password = str( self.login_ui.password.text()).strip() # get password self.storj_client = storj.Client(email=self.email, password=self.password) success = False # take login action - check credentials by listing keys :D try: self.storj_client.key_list() success = True except storj.exception.StorjBridgeApiError as e: j = json.loads(str(e)) if j.get("error") == "Invalid email or password": QtGui.QMessageBox.about( self, "Warning", "Invalid email or password - access denied. " "Please check your credentials and try again!") else: QtGui.QMessageBox.about(self, "Unhandled exception", "Exception: " + str(e)) if success: self.account_manager = AccountManager( self.email, self.password) # init account manager self.account_manager.save_account_credentials( ) # save login credentials and state msgBox = QtGui.QMessageBox(QtGui.QMessageBox.Information, "Success", "Successfully loged in!", QtGui.QMessageBox.Ok) result = msgBox.exec_() if result == QtGui.QMessageBox.Ok: self.__logger.info("User {} succesfully logged in".format( self.email)) self.main_ui_window = MainUI(self) self.main_ui_window.show() self.close()
def register(self): # validate fields self.email = self.register_ui.email.text() self.password = self.register_ui.password.text() self.password_repeat = self.register_ui.password_2.text() self.bridge_api_url = str( self.register_ui.bridge_url.text()).strip() # get bridge api url if len(self.bridge_api_url) < 6: # xxx.yy self.bridge_api_url = 'https://api.storj.io/' self.tools = Tools() success = False if self.email != '' and self.password != '' and self.password_repeat != '': if self.password == self.password_repeat: if (self.tools.check_email(self.email)): # take login action try: self.storj_client = storj.Client( None, '', storj_bridge=self.bridge_api_url).user_create( str(self.email).strip(), str(self.password).strip()) success = True except storj.exception.StorjBridgeApiError as e: j = json.loads(str(e)) if j[0]['error'] == 'Email is already registered': QtGui.QMessageBox.about( self, 'Warning', 'User with this e-mail is \ already registered! Please \ login or try a different \ e-mail!') else: QtGui.QMessageBox.about(self, 'Unhandled exception', 'Exception: ' + str(e)) else: QtGui.QMessageBox.about( self, 'Warning', 'Your e-mail \ seems to be invalid! Please check \ e-mail and try again') else: QtGui.QMessageBox.about( self, 'Warning', 'Given passwords are different! Please\ check and try again!') else: QtGui.QMessageBox.about(self, 'Warning', 'Please fill out all fields!') if success: msgBox = QtGui.QMessageBox( QtGui.QMessageBox.Information, 'Success', 'Successfully registered to Storj!' 'Verify your email by clicking on the' 'link that was sent to you.' 'Then, you can login.', QtGui.QMessageBox.Ok) logger.debug('New user registrated') logger.debug('Email: %s' % self.email) logger.debug('Password: %s' % self.password) result = msgBox.exec_() if result == QtGui.QMessageBox.Ok: self.login_window = LoginUI(self) self.login_window.show() self.close()