Пример #1
0
def loginn(request):
    
    page = 'Login'
    module = 'Login'
    args = {}
    args.update(csrf(request))
    if request.method == 'POST':
        args['email']= request.POST['email']
        args['error_message']=[]
        args = emailid_validate(request,args)
        if args['error_message']:
            return render_to_response('login/tologin.html',args)            
        loginlist = validate_login(request) 
## If the emailid exists, then call the page according to the role
        if (loginlist==1):      
            return HttpResponseRedirect("/get_multi_roles/")
## If the emailid does not exist,display error message
        elif (loginlist == 0):
             return HttpResponseRedirect("/blendedadmin_home/")
        elif (loginlist == 2):
             return HttpResponseRedirect("/bmchome")
        elif (loginlist == 3):
             return HttpResponseRedirect("/courseadminhome/")
        elif (loginlist == 4):
            error_message=retrieve_error_message(module,page,'LN_INV')##required to create error content message           
            args['error_message']=error_message
            return render_to_response('login/tologin.html',args)              

        else:
            error_message=retrieve_error_message(module,page,'LN_INV')            
            args['error_message']=error_message
            return render_to_response('login/tologin.html',args)            
    return render_to_response('login/tologin.html',args)
Пример #2
0
def forgot_pass(request):
    module = 'Login'
    page = 'Forgot_Pass'
    args = {}
    args.update(csrf(request))
    if request.method == 'POST':        
        email = request.POST['email']
        per_id= validate_email(email)
## If valid email id, then a mail is sent to his email alongwith a link to reset his password 
        if per_id != -1:     
            args['message']= retrieve_error_message(module,page,'NO_ERR')
            try:
               ec_id = EmailContent.objects.get(systype='Login', name='resetpass').id
            except:
               args['message'] ="Email cannot send at this moment. "
               return render(request,'geterror.html',args)
           #print ec_id
            send_email(request,ec_id, per_id, per_id)
            return render_to_response('login/forgot_pass.html',args)      
                           
        else:
## If invalid email, displays an error message
            args['message']=retrieve_error_message(module,page,'EML_INV')
            return render_to_response('login/forgot_pass.html',args)        
    return render_to_response('login/forgot_pass.html',args)
Пример #3
0
def change_pass(request):
   
    module = 'Login'
    page = 'Reset_Pass'
    args={}
    args.update(csrf(request))
    if request.method == 'POST':
       args={}
       try: 
		   
		   args.update(csrf(request))
		   args['old_password']=oldpwd=request.POST.get('old_password','').strip()
		   user=User.objects.get(username=request.session['email_id'])
		   args['password1']=password1= request.POST.get('new_password1','').strip()
		   args['password2']=password2= request.POST.get('new_password2','').strip()
		   args['message']=[]
		   
		   per_id=Personinformation.objects.get(email=request.session['email_id']).id
		   if args['message']:
			  return render_to_response('login/changepass.html',args)
		   else: 
		       
		         if user.check_password(oldpwd):
			        
			        if  len(password1)==0 or len(password2)==0 or password1 != password2:
				        
				        args['message']= retrieve_error_message(module,page,'NO_MTCH')
				        return render_to_response('login/changepass.html',args)

			        else:  
		  ## If the two new passwords match, password is changed and a mail is sent to the user regarding the change 
				            
				        user.set_password(password1)
				        user.save()
                     
				        args['message']= retrieve_error_message(module,page,'PWD_SET')
				        ec_id = EmailContent.objects.get(systype='Login', name='success').id
				        send_email(request,ec_id, per_id, per_id)
                        
				        del request.session['person_id']
				        del request.session['email_id']
				        del request.session['institute_id']
				        request.session.flush()
				        cache.clear()
				        auth.logout(request)
		#return HttpResponseRedirect('/')
				        
				        #response['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
				        #response.delete_cookie()
	
				        return render_to_response('login/change_pwdsuccess.html',args)            
		         args['message']= "old password incorrect"
		         return render_to_response('login/changepass.html',args)
       except:
               
               args['error_message']="you are not logged in.Please login to change your password"
               return render_to_response('login/tologin.html',args)
    return  render_to_response('login/changepass.html',args)
Пример #4
0
def loginn(request):
    page = 'Login'
    module = 'Registration'
    args = {}
    args.update(csrf(request))
    if request.method == 'POST':
        
	
        list1 = validate_login(request)
        
        if (list1!=-1):      
            
            args['institutename']=list1[1]            
            args['firstname']=list1[2]
            args['lastname']=list1[3]
            #return render_to_response('login/login_success.html',args)
            return ccourse(request)
        else:
            error_message=retrieve_error_message (module,page,'LN_INV')
            args = {}
            args.update(csrf(request))
            args['error_message']=error_message
            return render_to_response('login/tologin.html',args)            

            #return HttpResponseRedirect('/login_success/')
    args = {}
    args.update(csrf(request))        
    return render_to_response('login/tologin.html',args)
Пример #5
0
def createpass(request,personid):
    emailid = signer.unsign(personid)
    per_id = emailid
    module = 'Login'
    page = 'Reset_Pass'
    args = {}
    args.update(csrf(request))
    try:
       userid=Personinformation.objects.get(id=emailid)
       
       if Userlogin.objects.get(user=User.objects.get(email=userid.email)).status==False:   
		  

		     args['password1']=password1= request.POST.get('new_password1','')
		     args['password2']=password2= request.POST.get('new_password2','')
		     args['message']=[]
		     args = pwd_field_empty(request,args,'')
		     if args['message']:
		        return render_to_response('login/createpass.html',args)

		     if  len(password1)==0 or len(password2)==0 or password1 != password2:
		        args['message']= retrieve_error_message(module,page,'NO_MTCH')
		        return render_to_response('login/createpass.html',args)

		     else:  
	  ## If the two new passwords match, password is changed and a mail is sent to the user regarding the change 
		                 
		        userid=Personinformation.objects.get(id=emailid)           
		        user = User.objects.get(email=userid.email)           
		        user.set_password(password1)
		        user.save()
		        user_info=Userlogin.objects.get(user=user)
		        user_info.status=1
		        user_info.save()
		        args['message']= retrieve_error_message(module,page,'PWD_SET')
		        ec_id = EmailContent.objects.get(systype='Login', name='success').id
		        send_email(request,ec_id, per_id, per_id)
		        return render_to_response('login/create_pwdsuccess.html',args)            
	  
		  #return render_to_response('login/createpass.html',args)
       return  render_to_response('login/alreadycreated.html',args)

    except:
           args['message'] ="person  does not exist"
           return render(request,'geterror.html',args)