vesta-web 1.1.10__py3-none-any.whl → 1.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vesta/__init__.py CHANGED
@@ -101,26 +101,27 @@ class Server(server):
101
101
  self.sendVerification(user)
102
102
 
103
103
  @server.expose
104
- def login(self, email, password, parrain=None):
105
- if 'email' and 'password':
106
- password = password.encode('utf-8') # converting to bytes array
107
- account = self.uniauth.getUserCredentials(email)
108
- # If account exists in accounts table
109
- if account:
110
- msg = self.connect(account, password)
111
- else:
112
- msg = self.register(email, password, parrain)
104
+ def login(self, email=None, password=None, parrain=None):
105
+ if not email or not password:
106
+ return 'please give an email and a password'
107
+
108
+ password = password.encode('utf-8') # converting to bytes array
109
+ account = self.uniauth.getUserCredentials(email)
110
+ # If account exists in accounts table
111
+ if account:
112
+ msg = self.connect(account, password)
113
113
  else:
114
- msg = 'please give an email and a password'
114
+ msg = self.register(email, password, parrain)
115
115
 
116
116
  return msg
117
117
 
118
118
  @server.expose
119
- def changePasswordVerif(self,mail, code, password):
120
- id = self.uniauth.getSomething("account", mail,"email")["id"]
121
- if not id :
119
+ def changePasswordVerif(self, mail, code, password):
120
+ account = self.uniauth.getSomething("account", mail, "email")
121
+ if not account or not account.get("id"):
122
122
  return "no account found for " + mail
123
123
 
124
+ id = account["id"]
124
125
  password = password.encode('utf-8')
125
126
  actual = self.uniauth.getSomething("reset_code", id)
126
127
  if actual and str(actual["code"]) == code and actual["expiration"] > datetime.datetime.now():
@@ -152,7 +153,7 @@ class Server(server):
152
153
  user = self.getUser(verif=True)
153
154
  print("user:", user)
154
155
  actual = self.uniauth.getSomething("verif_code", user)
155
- if str(actual["code"]) == code and actual["expiration"] > datetime.datetime.now():
156
+ if actual and str(actual["code"]) == code and actual["expiration"] > datetime.datetime.now():
156
157
  self.uniauth.edit("account", user, "verified", True)
157
158
  self.createJwt(user, True)
158
159
  self.onLogin(user)
@@ -162,7 +163,11 @@ class Server(server):
162
163
 
163
164
  @server.expose
164
165
  def logout(self):
165
- token = self.getJWT()
166
+ try:
167
+ token = self.getJWT()
168
+ except:
169
+ pass # Cookie doesn't exist, that's fine
170
+
166
171
  self.response.del_cookie('JWT')
167
172
  self.response.del_cookie('auth')
168
173
  raise HTTPRedirect(self.response, "/auth")
vesta/http/baseServer.py CHANGED
@@ -82,6 +82,7 @@ class BaseServer:
82
82
  def wrapper(self, *args, **kwargs):
83
83
  res = func(self, *args, **kwargs)
84
84
  self.response.ok()
85
+ self.response.headers.append(('Server', 'Vesta v1 Harpie'))
85
86
  if res:
86
87
  if isinstance(res, bytes):
87
88
  return res
vesta/scripts/cli.py CHANGED
@@ -2,6 +2,7 @@ import argparse
2
2
  import os
3
3
  import subprocess
4
4
  from .utils import ex, Installer
5
+ from .initDB import DBInitializer
5
6
 
6
7
  HERE = os.path.dirname(__file__)
7
8
  PATH = os.getcwd()
@@ -191,7 +192,6 @@ def main():
191
192
  service_subparsers = parser_service.add_subparsers(dest='service_command')
192
193
  parser_service_setup = service_subparsers.add_parser('setup', help='Install systemd config')
193
194
 
194
-
195
195
  args = parser.parse_args()
196
196
 
197
197
  if args.command == 'init':
vesta/scripts/initDB.py CHANGED
@@ -18,27 +18,29 @@ class DBInitializer(Server):
18
18
 
19
19
  def referenceUniauth(self):
20
20
  self.db.cur.execute("CREATE EXTENSION if not exists postgres_fdw;")
21
- self.db.cur.execute(
22
- sql.SQL("""
23
- CREATE SERVER if not exists uniauth
24
- FOREIGN DATA WRAPPER postgres_fdw
25
- OPTIONS (host %s, port %s, dbname %s);
26
- """),
27
- (
28
- self.config.get('UNIAUTH', 'DB_HOST'),
29
- self.config.get('UNIAUTH', 'DB_PORT'),
30
- self.config.get('UNIAUTH', 'DB_NAME')
31
- ))
32
21
 
33
- self.db.cur.execute(
34
- sql.SQL("""
35
- CREATE USER MAPPING if not exists FOR CURRENT_USER SERVER uniauth
36
- OPTIONS (user %s, password %s);
37
- """),
38
- (
39
- self.config.get('DB', 'DB_USER'),
40
- self.config.get('DB', 'DB_PASSWORD')
41
- ))
22
+ ua_host = self.config.get('UNIAUTH', 'DB_HOST')
23
+ ua_port = self.config.get('UNIAUTH', 'DB_PORT')
24
+ ua_dbname = self.config.get('UNIAUTH', 'DB_NAME')
25
+ q_server = sql.SQL("""
26
+ CREATE SERVER IF NOT EXISTS uniauth
27
+ FOREIGN DATA WRAPPER postgres_fdw
28
+ OPTIONS (host {host}, port {port}, dbname {dbname});
29
+ """).format(
30
+ host=sql.Literal(ua_host),
31
+ port=sql.Literal(ua_port),
32
+ dbname=sql.Literal(ua_dbname)
33
+ )
34
+ self.db.cur.execute(q_server)
35
+
36
+ q_mapping = sql.SQL("""
37
+ CREATE USER MAPPING IF NOT EXISTS FOR CURRENT_USER SERVER uniauth
38
+ OPTIONS (user {user}, password {password});
39
+ """).format(
40
+ user=sql.Literal(self.config.get('DB', 'DB_USER')),
41
+ password=sql.Literal(self.config.get('DB', 'DB_PASSWORD'))
42
+ )
43
+ self.db.cur.execute(q_mapping)
42
44
  self.db.cur.execute(
43
45
  """
44
46
  CREATE FOREIGN TABLE if not exists account (id bigserial NOT NULL)
@@ -48,7 +50,7 @@ class DBInitializer(Server):
48
50
 
49
51
 
50
52
 
51
- initializer = DBInitializer(path=PATH[:-3], configFile="/server.ini", noStart=True)
52
- initializer.initUniauth()
53
- initializer.initDB()
54
- print("DB ready")
53
+ # initializer = DBInitializer(path=PATH[:-3], configFile="/server.ini", noStart=True)
54
+ # initializer.initUniauth()
55
+ # initializer.initDB()
56
+ # print("DB ready")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vesta-web
3
- Version: 1.1.10
3
+ Version: 1.2.1
4
4
  Summary: An extensive web framework adding every feature needed for Carbonlab
5
5
  Project-URL: Homepage, https://gitlab.com/Louciole/vesta
6
6
  Project-URL: Issues, https://gitlab.com/Louciole/vesta/-/issues
@@ -1,4 +1,4 @@
1
- vesta/__init__.py,sha256=B84n0xvfCLiCpXLpvPkjlEgGwBaxCzr0Xazm5e84mdo,17977
1
+ vesta/__init__.py,sha256=nK5NpQ_E9DbuhuoDNJsUdKdLVQ3PFK2Ou1fepo-92Q0,18106
2
2
  vesta/db/UNIAUTH.sql,sha256=3R8Si3rcXfRFC5idmaKTixDWXMazXQzdC9u1BCPCovY,2126
3
3
  vesta/db/db_service.py,sha256=E2r6LxxycMOBtpUXWbVIge_363QUCOIJg-MK-Z5dzmw,10058
4
4
  vesta/emptyProject/.gitignore,sha256=9ImxEbKZYcw6fZv2coknCwBdmfY7xWkrOgfBWR03VG0,206
@@ -45,18 +45,18 @@ vesta/emptyProject/static/translations/fr.mjs,sha256=ouMluPVTgB4Q5vmb7zGE6YGTH4U
45
45
  vesta/emptyProject/static/translations/translation.mjs,sha256=JxJ2peSlYVQK-bUKpfddPLXm0XZiz2yu6A6iWIqpKyM,1422
46
46
  vesta/emptyProject/static/ws/onMessage.mjs,sha256=ow5nwSEdiBcvm-Y2zOUMhnqLp-5xWgo11kHviaTRlTw,658
47
47
  vesta/emptyProject/tests/example/foo.py,sha256=NS9oIXFBOvIyWK1LHwkJm9amJuSMN4cxJwouBrJlh2I,115
48
- vesta/http/baseServer.py,sha256=ltfXhkqJQPcvKlUX1u5jUguPnodDslmM4t1BOO0ZVR8,15083
48
+ vesta/http/baseServer.py,sha256=Fc3eCGB3V9cj2KNiTUuw1N0T6mmg_H70iP9p2psgvnw,15155
49
49
  vesta/http/error.py,sha256=fWdp-oI2ObJD2mHHuxs1yVJvhON5oHYgYFRLAcUMs-I,180
50
50
  vesta/http/redirect.py,sha256=OiDeOmU-X5Mos8a0BQIeOIJqvgWjDEtaYrM4-x4MXl0,177
51
51
  vesta/http/response.py,sha256=G7cmbrXFNbIbQoqNxNkR06I5VymIwjFSAe3LtVa56Ok,3760
52
52
  vesta/mailing/mailing_service.py,sha256=GBO5Hnspm9Pqwd5kGB0iekZaMoIrfQvrhMUf8tVma7g,5386
53
- vesta/scripts/cli.py,sha256=AtC7hxB3sMH984e65msO2-R0s4nkrzP09Aqd3OPwCes,8224
54
- vesta/scripts/initDB.py,sha256=TKaK4RZM6CycBEsHeGb9Q9PdphkQgaJDnEWhvRnGC9k,1659
53
+ vesta/scripts/cli.py,sha256=8IHmL09-kzdp-FdqyFlO6cmgYKX5UcpdXdjQDXJpzHs,8257
54
+ vesta/scripts/initDB.py,sha256=4o_J3IK0vcil2oHvk_qmtqLSlWABcRPFBC3M61-oSF8,1842
55
55
  vesta/scripts/install.py,sha256=GvH_HHx5aU5_54RQ1_2vz4DaLCh42AHfUKy-m0q21vY,2125
56
56
  vesta/scripts/testsRun.py,sha256=bXJImdexKQUDW8CR8F9VIKTrgkd7QfnvHQPENEV4x38,2463
57
57
  vesta/scripts/utils.py,sha256=PR2XPonaoZEbegzV3QX1EHfyq67sU-cbDEUexCuJp9Q,6013
58
- vesta_web-1.1.10.dist-info/METADATA,sha256=vFJSmvsrvfNqk0S14S5Gggw4xDVoZuUBZZueNNh9gTQ,1585
59
- vesta_web-1.1.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
60
- vesta_web-1.1.10.dist-info/entry_points.txt,sha256=MHMrWJwtkb4FmNz0CTpxZzwQ3LTqndXBh8YBPDfXlW4,49
61
- vesta_web-1.1.10.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
62
- vesta_web-1.1.10.dist-info/RECORD,,
58
+ vesta_web-1.2.1.dist-info/METADATA,sha256=wQBkA51DKVeEg3DQPWEqLFZ0D1JqXcvkC3mhekIbxlQ,1584
59
+ vesta_web-1.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
60
+ vesta_web-1.2.1.dist-info/entry_points.txt,sha256=MHMrWJwtkb4FmNz0CTpxZzwQ3LTqndXBh8YBPDfXlW4,49
61
+ vesta_web-1.2.1.dist-info/licenses/LICENSE.md,sha256=zoPFEFUUoSgosmDBK5fGTWGRHHBaSVuuJT2ZQIYXuIk,177
62
+ vesta_web-1.2.1.dist-info/RECORD,,