예제 #1
0
def login():
	'''
	Log the user into the SprintBeard application. Results in the user being redirected to the Google OpenID process.
	'''
	#if we've already logged in, just redirect to the selected url	

	if 'openid' in session and 'user' not in session:
		session['user'] = Users.get_by_openid(session['openid'])
		return redirect(oid.get_next_url())
	else:
		return oid.try_login("https://www.google.com/accounts/o8/id",ask_for=['email', 'fullname'])
예제 #2
0
def new_user(resp):
	'''
	Creates a new user if the user had not previously signed in with openid. Otherwise, just sets the session to the correct user.
		arg: resp - the response from the openid provider

		return: the view to display (redirected to originally asked for page)
	'''
	session['openid'] = resp.identity_url
	user = Users.get_by_openid(session['openid'])
	#if we haven't created the user before, create it
	if user is None:
		user = Users.create(resp.fullname, resp.email)
		Users.create_openid_association(user.id, session['openid'])
		session['user'] = user
	else:
		session['user'] = user

	return redirect(oid.get_next_url())