Browse Source

use another session to get password update

Guénaël Muller 6 years ago
parent
commit
ccd6bfd13a

+ 1 - 1
backend/tracim_backend/lib/core/user.py View File

234
         )
234
         )
235
         if do_save:
235
         if do_save:
236
             # TODO - G.M - 2018-07-24 - Check why commit is needed here
236
             # TODO - G.M - 2018-07-24 - Check why commit is needed here
237
-            transaction.commit()
237
+            self.save(user)
238
         return user
238
         return user
239
 
239
 
240
     def set_email(
240
     def set_email(

+ 24 - 0
backend/tracim_backend/tests/functional/test_user.py View File

1774
             status=204,
1774
             status=204,
1775
         )
1775
         )
1776
         # Check After
1776
         # Check After
1777
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1778
+        uapi = UserApi(
1779
+            current_user=admin,
1780
+            session=dbsession,
1781
+            config=self.app_config,
1782
+        )
1777
         user = uapi.get_one(user_id)
1783
         user = uapi.get_one(user_id)
1778
         assert not user.validate_password('pass')
1784
         assert not user.validate_password('pass')
1779
         assert user.validate_password('mynewpassword')
1785
         assert user.validate_password('mynewpassword')
1829
             params=params,
1835
             params=params,
1830
             status=403,
1836
             status=403,
1831
         )
1837
         )
1838
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1839
+        uapi = UserApi(
1840
+            current_user=admin,
1841
+            session=dbsession,
1842
+            config=self.app_config,
1843
+        )
1832
         # Check After
1844
         # Check After
1833
         user = uapi.get_one(user_id)
1845
         user = uapi.get_one(user_id)
1834
         assert user.validate_password('pass')
1846
         assert user.validate_password('pass')
1887
             status=400,
1899
             status=400,
1888
         )
1900
         )
1889
         # Check After
1901
         # Check After
1902
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1903
+        uapi = UserApi(
1904
+            current_user=admin,
1905
+            session=dbsession,
1906
+            config=self.app_config,
1907
+        )
1890
         user = uapi.get_one(user_id)
1908
         user = uapi.get_one(user_id)
1891
         assert user.validate_password('pass')
1909
         assert user.validate_password('pass')
1892
         assert not user.validate_password('mynewpassword')
1910
         assert not user.validate_password('mynewpassword')
1944
             status=204,
1962
             status=204,
1945
         )
1963
         )
1946
         # Check After
1964
         # Check After
1965
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1966
+        uapi = UserApi(
1967
+            current_user=admin,
1968
+            session=dbsession,
1969
+            config=self.app_config,
1970
+        )
1947
         user = uapi.get_one(user_id)
1971
         user = uapi.get_one(user_id)
1948
         assert not user.validate_password('pass')
1972
         assert not user.validate_password('pass')
1949
         assert user.validate_password('mynewpassword')
1973
         assert user.validate_password('mynewpassword')