Subversion Repositories SmartDukaan

Rev

Rev 840 | Rev 884 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 840 Rev 873
Line 9... Line 9...
9
    Address, SocialHandle, UserState, InternalInfo, SocialService
9
    Address, SocialHandle, UserState, InternalInfo, SocialService
10
from shop2020.thriftpy.model.v1.user.ttypes import UserContextException,\
10
from shop2020.thriftpy.model.v1.user.ttypes import UserContextException,\
11
    AuthenticationException, AccountStatus, Sex
11
    AuthenticationException, AccountStatus, Sex
12
from shop2020.clients.HelperClient import HelperClient
12
from shop2020.clients.HelperClient import HelperClient
13
from elixir import session
13
from elixir import session
14
import datetime
14
import datetime, random, string
15
from shop2020.thriftpy.utils.ttypes import Mail
15
from shop2020.thriftpy.utils.ttypes import Mail
16
 
16
 
17
def initialize():
17
def initialize():
18
    log_entry("initialize@DataAccessor", "Initializing data service")
18
    log_entry("initialize@DataAccessor", "Initializing data service")
19
    Dataservice.initialize()
19
    Dataservice.initialize()
Line 292... Line 292...
292
 
292
 
293
def forgot_password(email):
293
def forgot_password(email):
294
    try:
294
    try:
295
        user = User.get_by(email=email)
295
        user = User.get_by(email=email)
296
        if user:
296
        if user:
-
 
297
            new_password = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(8))
297
            mail = Mail()
298
            mail = Mail()
298
            mail.to = []
299
            mail.to = []
299
            mail.to.append(email)
300
            mail.to.append(email)
300
            mail.sender = ""
301
            mail.sender = ""
301
            mail.password = ""
302
            mail.password = ""
302
            mail.data = "Your new password is " + user.password
303
            mail.data = "Your new password is " + user.password
303
            helper_client = HelperClient()
304
            helper_client = HelperClient()
304
            helper_client.__start__()
305
            helper_client.__start__()
305
            client = helper_client.get_client()
306
            client = helper_client.get_client()
306
            client.sendMail(mail);
307
            client.sendMail(mail);
-
 
308
            
307
            return True
309
            return True
308
        else:
310
        else:
309
            return False
311
            return False
310
    except:
312
    except:
311
        return False
313
        return False