Exemple #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))
Exemple #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))
 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))