def handle(request): account = siteaction.getLoggedInAccount(request) if not account: return HttpResponseRedirect('/login.htm') #TODO: notify user about success, success_page will change logged_in_type = siteaction.getLoggedInAccountType(request) if logged_in_type == 'U': entry_page = 'me/changeemail.htm' success_page = '/me/editsettings.htm?flashId=email_chnged' error_page = 'me/showmessage.htm' myself = siteaction.getLoggedInUser(request) elif logged_in_type == 'R': entry_page = 'recruiters/changeemail.htm' success_page = '/recruiters/' error_page = 'recruiters/showmessage.htm' myself = siteaction.getLoggedInRecruiter(request) if request.method == 'GET': return siteaction.render_to_response(entry_page, {'myself':myself}) elif request.method == 'POST': #Password Check if (siteaction.validatePassword(myself.account.id, dataplus.dictGetVal(request.REQUEST, 'password'))): result, errMsg = codejar_validation.validateEmail(dataplus.dictGetVal(request.REQUEST,'email')) if not result: return siteaction.render_to_response(error_page, {'myself':myself, 'msg_heading':'Error', 'msg_html':'Invalid user input.'}) email_address = dataplus.dictGetSafeVal(request.REQUEST, 'email') account.email = email_address account.save() myself.email = email_address myself.save() return HttpResponseRedirect(success_page) else: return siteaction.render_to_response(entry_page, {'error_html': '<p class="error-note">Password was incorrect. Try again.</p>'})
def handle(request): myself = siteaction.getLoggedInAccount(request) if not myself: return HttpResponseRedirect('/login.htm') #TODO: notify user about success, success_page will change logged_in_type = siteaction.getLoggedInAccountType(request) if logged_in_type == 'U': pwd_page = 'me/changepassword.htm' success_page = '/me/editsettings.htm?flashId=pwd_chnged' elif logged_in_type == 'R': pwd_page = 'recruiters/changepassword.htm' success_page = '/recruiters/' if request.method == 'GET': return siteaction.render_to_response(pwd_page, {'myself':myself}) elif request.method == 'POST': #Password length >= 6 and <=12 valid, invalid_msg = dataplus.isLengthValid(dataplus.dictGetVal(request.REQUEST, 'password1'), 6, 12, 'Password') if not valid: return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">' + invalid_msg + '</p>'}) #Passwords should match if dataplus.dictGetVal(request.REQUEST, 'password1') != dataplus.dictGetVal(request.REQUEST, 'password2'): return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">Passwords do not match.</p>'}) #Is the Old Password Check if (siteaction.validatePassword(myself.id, dataplus.dictGetVal(request.REQUEST, 'oldpassword'))): myself.password = dataplus.hash(dataplus.dictGetVal(request.REQUEST, 'password1')) myself.save() return HttpResponseRedirect(success_page) else: return siteaction.render_to_response(pwd_page, {'error_html': '<p class="error-note">Old password was incorrect. Try again.</p>'})