def reportErrorMessageToAdmin(fehlermeldung, subject, userid): email_msg = '\nEs wurde folgende Benachrichtigung ueber das Portal VK2.0. gestellt.\n\nEmail: {email}\nLogin: {userid}\nReferenz: {referencer}\nNachricht: {message}\n'.format( email=str(fehlermeldung.email), userid=str(userid), referencer=str(fehlermeldung.referenz), message=str(fehlermeldung.fehlerbeschreibung)) sendMailCommandLine(admin_mail, subject, email_msg)
def reset_pw(request): dbsession = request.db try: login = request.params['username'] email = request.params['email'] if not login or not email: raise MissingQueryParameterError( 'Missing information for reset password process.') if 'form.submitted' in request.params: user = Users.by_username(login, dbsession) if user and user.email == email: # register ticket in database newTicket = Fehlermeldung(fehlerbeschreibung="Passwort reset", timestamp=getTimestampAsPGStr(), referenz="users", nutzerid=user.login, objektid=user.id) dbsession.add(newTicket) # reset password newPassword = generateRandomString(10) user._set_password(newPassword) # send new password reset_msg = password_reset_msg.format( user=str(user.login), new_password=str(newPassword)) response = sendMailCommandLine( user.email, 'Your password has been changed!', reset_msg) if not response: raise InternalAuthentificationError( 'Internal server error while trying to send you your new password. Please try again or contact the page administrator.' ) # create response target_url = request.route_url('auth', action='page_reset_success') transaction.commit() return HTTPFound(location=target_url) else: raise InternalAuthentificationError( 'Internal server error while trying to change password. Please try again or contact the page administrator.' ) else: raise MissingQueryParameterError('Missing form validation.') except MissingQueryParameterError, InternalAuthentificationError: raise
def reset_pw(request): dbsession = request.db try: login = request.params['username'] email = request.params['email'] if not login or not email: raise MissingQueryParameterError('Missing information for reset password process.') if 'form.submitted' in request.params: user = Users.by_username(login, dbsession) if user and user.email == email: # register ticket in database newTicket = Fehlermeldung(fehlerbeschreibung="Passwort reset", timestamp=getTimestampAsPGStr(), referenz="users", nutzerid=user.login, objektid=user.id); dbsession.add(newTicket); # reset password newPassword = generateRandomString(10) user._set_password(newPassword) # send new password reset_msg = password_reset_msg.format(user = str(user.login), new_password = str(newPassword)) response = sendMailCommandLine(user.email, 'Your password has been changed!', reset_msg) if not response: raise InternalAuthentificationError('Internal server error while trying to send you your new password. Please try again or contact the page administrator.') # create response target_url = request.route_url('auth', action='page_reset_success') transaction.commit() return HTTPFound(location = target_url) else: raise InternalAuthentificationError('Internal server error while trying to change password. Please try again or contact the page administrator.') else: raise MissingQueryParameterError('Missing form validation.') except MissingQueryParameterError, InternalAuthentificationError: raise
def testSendMailCommandLine(self): response = sendMailCommandLine('*****@*****.**', 'Test mail', 'This email is send for testing purpose') print 'Function testSendMailCommandLine - response = %s '%response self.assertTrue(response, 'Function testSendMailCommandLine - Failed because response is not True.')
def reportErrorMessageToAdmin(fehlermeldung, subject, userid): email_msg = '\nEs wurde folgende Benachrichtigung ueber das Portal VK2.0. gestellt.\n\nEmail: {email}\nLogin: {userid}\nReferenz: {referencer}\nNachricht: {message}\n'.format( email = str(fehlermeldung.email), userid = str(userid), referencer = str(fehlermeldung.referenz), message = str(fehlermeldung.fehlerbeschreibung)) sendMailCommandLine(admin_mail, subject, email_msg)