Example #1
0
def validLogin(postForm):
	'''
	Given email and password, authorize user 
	to access Virtual Admin Dashboard
	'''
	usr_name = postForm['email'].split('@')[0]
	psswrd = ut.hashPassword(postForm['password'])

	try:
		chapter = c_chapters.find({ 'email':postForm['email'], 'password':psswrd })[0]
	except IndexError:
		chapter = None

	if chapter:	#If entry found do...
		if chapter['email_confirmed'] == True:
			fl.session['usrName'] = usr_name
			fl.session['password'] = psswrd
			return True
		else:
			return False
	else:
		return False
Example #2
0
def signUpUser(postForm):
	newUser = True
	fl.session['usrName'] = postForm['email'].split('@')[0]
	fl.session['password'] = ut.hashPassword(postForm['password'])
	post = {
		'email': postForm['email'],
		'name': fl.session['usrName'],
		'password': fl.session['password'],
		'joined_on': ut.dateNow(),
		'email_confirmed': False,
		'gfolder_link':None,
		'w_agenda_date':None,
		'integrations': {
			'asana': {
				'auth_token':None		
			},
			'gdrive': {
				'client_id':None,
				'client_secret':None,
				'scope':None,
				'redirect_uri':None	
			},
			'slack':{
				'auth_token':None,
				'webhook_url':None
			},
			'twilio':{
				'accnt_sid':None,
				'auth_token':None,
				'twilio_num':None,
			}
		},
		'members': {
			'Add-member': {
				'email': None,
				'phone_num': None,
				'reminder_pref': None
			}
		},
		'organization': None
	}

	try:
		chapter = c_chapters.find({ 'email':postForm['email'] })[0]
	except IndexError:
		chapter = None

	if chapter:
		newUser = False

	if newUser:
		c_chapters.insert_one(post)
		status = None
	elif newUser and postForm['password'] == None:
		status = 'Password is a required field!'
	elif not newUser and postForm['password'] == None:
		status = 'Password is a required field!'
	else:
		status = 'There already exists an account with the email {0}. Please Log in here: {1}/login'.format(usr_email, host_url)

	return status