def openid_createuser(request): person = openidgae.get_current_person(request, http.HttpResponse()) email = person.get_email() res = util_externals.reponse_if_exists(email) if res is not None: return res nick = util_externals.get_nick_from_email(email) params = { 'nick': nick, 'password': util.generate_password(), 'first_name': person.get_field_value('firstname', 'none'), 'last_name': person.get_field_value('lastname', 'none'), 'fromopenid': True, 'email':email, } actor_ref = util_externals.user_create('google', params, util.display_nick(email), email) # NOTE: does not provide a flash message response = util.RedirectFlash('/', 'Welcome to %s' % util.get_metadata('SITE_NAME')) user.set_user_cookie(response, actor_ref) return response
def twitter_user_create(request): twitter_user, token = util_externals.twitter_user() if not twitter_user: c = template.RequestContext(request, locals()) t = loader.get_template('poboxopenid/templates/twitter_login.html') return http.HttpResponse(t.render(c)) res = util_externals.reponse_if_exists(twitter_user.id, 'twitter') if res is not None: return res nick = util_externals.get_nick_from_email(twitter_user.screen_name) params = { 'nick': nick, 'password': util.generate_password(), 'first_name': twitter_user.name, 'last_name': '', 'fromopenid': True, 'email':None, } actor_ref = util_externals.user_create('twitter', params, twitter_user.screen_name, str(twitter_user.id), 'http://twitter.com/%s'%twitter_user.screen_name) logging.info("Storing twitter_access_token after create a user") actor_ref.extra['twitter_access_token'] = token actor_ref.put() response = util.RedirectFlash('/', 'Welcome to P.O.BoxPress') user.set_user_cookie(response, actor_ref) return response #@decorator_from_middleware(FacebookMiddleware) #@facebook.require_login('/facebook/signin', False) #def facebook_processuser(request): # c = template.RequestContext(request, locals()) # t = loader.get_template('poboxopenid/templates/facebook_login.html') # return http.HttpResponse(t.render(c)) #@decorator_from_middleware(FacebookMiddleware) #@facebook.require_login('/facebook/signin', False) #def facebook_canvas(request): # values = request.facebook.users.getInfo([request.facebook.uid], ['first_name', 'is_app_user', 'has_added_app'])[0] # # name, is_app_user, has_added_app = values['first_name'], values['is_app_user'], values['has_added_app'] # # if has_added_app == '0': # return request.facebook.redirect(request.facebook.get_add_url()) # # c = template.RequestContext(request, locals()) # t = loader.get_template('poboxopenid/templates/canvas.fbml') # return http.HttpResponse(t.render(c))