]> git.pld-linux.org Git - projects/pld-ftp-admin.git/blame - modules/user.py
Fix list and iterators assumptions that are no longer valid in python3
[projects/pld-ftp-admin.git] / modules / user.py
CommitLineData
1610d209
MM
1# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
2
2ec96333
JR
3from __future__ import print_function
4
6992b18d 5import Cookie, time, ftpio
1610d209
MM
6
7UserNotLoggedIn="UserNotLoggedIn"
8
9class User:
10 def __init__(self, cookies, options):
11 self.loggedin=False
a2a38501 12 ftpio.connect('wwwiface')
6992b18d
MM
13 if 'ftpsessid' in cookies and cookies['ftpsessid']:
14 self.login=ftpio.login_cookie(cookies['ftpsessid'])
15 if self.login:
16 self.loggedin=True
1610d209 17
6992b18d 18 if 'action' in options:
1610d209
MM
19 if options['action'] == 'register':
20 self.checkloginpass(options)
21 elif options['action'] == 'logout':
22 self.logout()
23
24 def checkloginpass(self, options):
6992b18d 25 if 'login' not in options or 'pass' not in options:
1610d209 26 return
6992b18d
MM
27 self.cookie=ftpio.login_passwd(options['login'], options['pass'])
28 if self.cookie:
29 self.login=options['login']
30 self.loggedin=True
1610d209 31 C = Cookie.SimpleCookie()
6992b18d
MM
32 C['ftpsessid']=self.cookie
33 #C['ftpsessid']['expires']=time.strftime(
34 #"%a, %d-%b-%y %H:%M:%S GMT",
35 #time.gmtime(time.time()+86400))
2ec96333
JR
36 print(C)
37
6992b18d
MM
38 def logout(self):
39 self.loggedin=False
40 ftpio.logout()
41 C = Cookie.SimpleCookie()
42 C['ftpsessid']=''
43 C['ftpsessid']['expires']=time.strftime("%a, %d-%b-%y %H:%M:%S GMT",
44 time.gmtime(time.time()-31536000))
2ec96333 45 print(C)
1610d209 46
This page took 1.240658 seconds and 4 git commands to generate.