def signup_openid_callback(request): consumer = Consumer(request.session, DjangoOpenIDStore()) redirect_to = 'http://'+settings.SEYMOUR_DOMAIN+'/signup/openid/' openid_response = consumer.complete(dict(request.GET.items()), redirect_to) if openid_response.status == SUCCESS: try: account = Account.objects.get(openid=openid_response.identity_url) except Account.DoesNotExist: account = Account(openid=openid_response.identity_url, last_login=datetime.datetime.now(), is_active=True) account.save() request.session['account_id'] = account.id return HttpResponseRedirect('/feeds/unread/') else: error_msg = "An account for that openid already exists." elif openid_response.status == CANCEL: error_msg = "The request was cancelled" elif openid_response.status == FAILURE: error_msg = openid_response.message elif openid_response.status == SETUP_NEEDED: error_msg = "Setup needed" else: error_msg = "Bad openid status: %s" % openid_response.status return render_to_response('accounts/signup_error.html', { 'error_msg': error_msg, 'section': 'signup', }, context_instance=RequestContext(request))
def save(self): data = self.cleaned_data account = Account( firstname=data['firstname'], lastname=data['lastname'], email=data['email'], is_active=True, ) account.set_password(data['password']) account.save() # email the password to the user from django.core.mail import send_mail from django.template import Template, Context, loader context = Context({ 'account': account, 'password': data['password'], 'sitename': settings.SITENAME, 'seymour_domain': settings.SEYMOUR_DOMAIN }) subject = u"Welcome to %s" % (settings.SITENAME) t = loader.get_template('emails/account_added.email') email_body = t.render(context) if settings.DEBUG: print "Subject: " + subject.encode('utf8') print "-"*80 print email_body.encode('utf8') else: send_mail(subject, email_body, settings.EMAIL_FROM, [account.email], fail_silently=True) return account