Exemple #1
0
def passwordSendEmail(request, format=None):
    if request.method == 'PUT':
        data = JSONParser().parse(request)
        email = getPropertyByName('email', data.items())
        token = getPropertyByName('token', data.items())

        if correctForgotPasswordToken(email, token):
            TO = email
            tmpPassword = tokenGenerator()
            code = md5Encoding(tmpPassword)
            SUBJECT = "AliveTracker reset password message. (DO NOT REPLY)"
            FROM = "*****@*****.**"
            MESSAGE = """
            You requested to have your password reset, below is your new password.

                      Username:""" + TO + """
                      New Password: """ + tmpPassword + """

                      To login your new password, please go to
                      http://www.alivetracker.com
            Thanks,
            AliveTracker Team"""
            try:
                User.objects.filter(email=TO).update(password=code, entity_status=2)
            except:
                return responseJsonUtil(False, 'ERROR000', None)
            try:
                sendEmail(FROM, TO, SUBJECT, MESSAGE)
                return responseJsonUtil(True, None, None)
            except:
                return responseJsonUtil(False, 'ERROR002', None)
        else:
            return responseJsonUtil(False, 'ERROR100', None)
Exemple #2
0
def forgotPassword(request, format=None):
    if request.method == 'PUT':
        data = JSONParser().parse(request)
        TO = getPropertyByName('email', data.items())
        if emailExists(TO):
            code = md5Encoding(tokenGenerator())
            SUBJECT = "AliveTracker forgot password instructions. (DO NOT REPLY)"
            FROM = "*****@*****.**"
            MESSAGE = """
            Hey, we heard you lost your AliveTracker password.
            Use the following link to reset your password:

                     http://www.alivetracker.com/#resetPasswordPage?email=""" + TO + """&token=""" + code + """

            Ignore this email if you haven't experienced any password trouble.

            Thanks,
            AliveTracker Team"""
            try:
                tmpUser = User.objects.get(email=TO)
                User_Forgot_Password.objects.get_or_create(user=tmpUser)
                User_Forgot_Password.objects.filter(user=tmpUser).update(token=code)
            except:
                return responseJsonUtil(False, 'ERROR000', None)
            try:
                sendEmail(FROM, TO, SUBJECT, MESSAGE)
                return responseJsonUtil(True, None, None)
            except:
                return responseJsonUtil(False, 'ERROR002', None)
        else:
            return responseJsonUtil(False, 'ERROR102', None)
Exemple #3
0
def onUserInvitationEmail(FROM, TO, temporallyPassword ):
    SUBJECT="You were invited to join to Spuras app"
    MESSAGE = """
           Hello,You are inviting to join to Spuras application,
            Spuras generate a temporally password special for you:

            password: """ + temporallyPassword + """

            To login to our  app, please go to:

            http://www.alivetracker.com/Spuras/#loginPage

            As Advise, change the password after login in to the application

            Ignore this email if you haven't experienced any password trouble.

            Thanks,
            AliveTracker Team"""

    sendEmail(FROM, TO, SUBJECT, MESSAGE)