AiC and REST login
[myslice.git] / portal / joinview.py
index 721efcf..d4e4af5 100644 (file)
@@ -9,7 +9,6 @@ from django.views.generic       import View
 from django.template.loader     import render_to_string
 from django.shortcuts           import render
 from django.contrib.auth        import get_user_model
-from django.contrib.sites.models import Site
 
 from unfold.page                import Page
 from unfold.loginrequired       import FreeAccessView
@@ -22,6 +21,7 @@ from portal.models              import PendingUser,PendingAuthority
 from portal.actions             import authority_get_pi_emails, manifold_add_user,manifold_add_account, create_pending_user
 
 from myslice.theme import ThemeView
+from myslice.settings import logger
 
 import activity.institution
 
@@ -154,9 +154,12 @@ class JoinView (FreeAccessView, ThemeView):
  
                 reg_password = request.POST['pi_password']
                 salt = randint(1,100000)
-                # get the domain url
-                current_site = Site.objects.get_current()
-                current_site = current_site.domain
+
+                if request.is_secure():
+                    current_site = 'https://'
+                else:
+                    current_site = 'http://'
+                current_site += request.META['HTTP_HOST']
 
                 email_hash = md5(str(salt)+reg_email).hexdigest()
                 user_request = {
@@ -173,7 +176,7 @@ class JoinView (FreeAccessView, ThemeView):
                     'user_hrn'      : user_hrn,
                     'pi'            : [reg_auth],
                     'auth_type'     : 'managed',
-                    'validation_link': 'https://' + current_site + '/portal/email_activation/'+ email_hash
+                    'validation_link': current_site + '/portal/email_activation/'+ email_hash
                 }
 
                 
@@ -229,9 +232,9 @@ class JoinView (FreeAccessView, ThemeView):
                     msg.send()
     
                 except Exception, e:
-                    print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+                    logger.error("Failed to send email, please check the mail templates and the SMTP configuration of your server")
                     import traceback
-                    traceback.print_exc()
+                    logger.error(traceback.format_exc())
 
                 self.template_name = 'join_complete.html'
                 # log institution activity