예제 #1
0
	def login(self):
		''' Login function. Realize login to application
			using terminal and validation user credentials
			using file with credentials and CryptObject.
		'''
		inpt = raw_input('If your`re registered user enter `Sign In` or press Enter\n \
 					\relse enter `Registration` to registrate new User.\n \
 					\r>')
		if inpt.lower() == 'sign in' or inpt == '':
			while True:
				name = raw_input('Enter your name: ')
				passwd = getpass('Enter your password: '******'r')		#add valid credential
					if credentials.decrypt_user_credentials(name, 				#validation credentials
															passwd, x[:-1])]	#func return True if valid
				if len(cred_data) == 1:
					print 'Successfuly logined'
					if self.user_folder_name == '':
						self.user_folder_name = cred_data[0][:10]						#use first ten symbols for user's folder name for saving wprking files
					show = self.terminal_interaction
					if os.listdir(self.user_folder_name) == []:
						print 'Your working directory is empty'
					else:
						print 'Files in your working directory:'
						show('ls %s' % self.user_folder_name)
						print
					break
				print 'Your login or password is wrong try one more time!'
		else:
			self.registration()
예제 #2
0
	def registration(self):
		''' Registration function. Realize reginstration to
			application and adding user credentials to 
			credentials.txt. Creat user working folder.
		'''
		print 'Registration Form'
		name = raw_input('Enter your name: ')
		while True:
			passwd1 = getpass('Enter your password: '******'Enter your password: '******'Incorrect password'
		credentials = CryptObject()
		data = credentials.encrypt_user_credentials(name, passwd1)
		self.user_folder_name = data[:10]								#use first ten symbols for user's folder name for saving wprking files
		create = self.terminal_interaction
		create('mkdir %s' % self.user_folder_name)						#create working folder
		with open(self.credentials_file, 'a') as cred_data:
			cred_data.write(data + '\n')
		cred_data.close()
		self.login()