Esempio n. 1
0
 def post(self, request, *args, **kwargs):
     form = CreateUserForm(request.POST)
     if form.is_valid():
         if SessionManager.user_exists(email=request.POST['email']):
             messages.error(
                 request, 'A user with this email address already exists.')
             self.context.update({
                 'form': form,
             })
             return HttpResponse(self.template.render(
                 self.context, request))
         else:
             user = SessionManager.create_user(
                 email=request.POST['email'],
                 username=request.POST['username'],
                 password=request.POST['password'])
             messages.success(
                 request,
                 'Registration complete! Please log in to continue.')
             return redirect(reverse('session_manager_login'))
     else:
         self.context.update({
             'form': form,
         })
         return HttpResponse(self.template.render(self.context, request))
Esempio n. 2
0
 def post(self, request, *args, **kwargs):
     form = CreateUserForm(request.POST)
     if form.is_valid():
         user = SessionManager.create_user(
             email=request.POST['email'],
             password=request.POST['password'],
             first_name=request.POST['first_name'],
             last_name=request.POST['last_name'])
         messages.success(
             request, 'Registration complete! Please log in to continue.')
         return redirect(reverse('session_manager_login'))
     else:
         self.context.update({
             'form': form,
         })
         return HttpResponse(self.template.render(self.context, request))
Esempio n. 3
0
    def get(self, request, *args, **kwargs):
        if not self.registration_token:
            messages.error(request, self.token_error_message)
            return redirect(reverse('session_manager_login'))
        elif not self.registration_token.is_valid:
            self.registration_token.delete()
            messages.error(request, 'Registration link invalid or expired')
            return redirect(reverse('session_manager_login'))
        else:
            if self.registration_type == 'website':
                init_email = self.appuser.email
                if settings.MAKE_USERNAME_EMAIL:
                    init_username = self.appuser.email
                else:
                    init_username = None
            else:
                init_email = None
                init_username = None

            initial = {
                'email': init_email,
                'username': init_username,
                'appuseruuid': self.appuser.uuid,
            }
            form = CreateUserForm(self.registration_type, initial=initial)
        self.context.update({
            'form': form,
        })
        return HttpResponse(self.template.render(self.context, request))
Esempio n. 4
0
 def post(self, request, *args, **kwargs):
     form = CreateUserForm(self.registration_type, request.POST)
     if form.is_valid():
         appuser = AppUser.objects.get(uuid=request.POST['appuseruuid'])
         if not settings.MAKE_USERNAME_EMAIL:
             username = request.POST['username']
         else:
             username = request.POST['email']
         if self.registration_type == 'invitation':
             user = User(email=request.POST['email'], username=username)
             user.save()
             appuser.user = user
             appuser.save()
         user = appuser.user
         SessionManager.register_user(
             user,
             username=username,
             password=request.POST['password'],
             first_name=request.POST['first_name'],
             last_name=request.POST['last_name']
         )
         messages.success(request, 'Registration complete! Please log in to continue.')
         UserToken.objects.filter(
             appuser=appuser,
             token_type__in=['registration', 'invitation']
         ).all().delete()
         self.appuser.post_process_registration(self.registration_type, user)
         return redirect(reverse('session_manager_login'))
     else:
         self.context.update({
             'form': form,
         })
         return HttpResponse(self.template.render(self.context, request))
     self.context.update({
         'form': form,
     })
     return HttpResponse(self.template.render(self.context, request))
Esempio n. 5
0
 def get(self, request, *args, **kwargs):
     form = CreateUserForm()
     self.context.update({
         'form': form,
     })
     return HttpResponse(self.template.render(self.context, request))