@@ -19,12 +19,12 @@ const CoCreateUser = {
19
19
const self = this ;
20
20
crud . listen ( 'createUser' , function ( data ) {
21
21
self . setDocumentId ( 'users' , data . document_id ) ;
22
- document . dispatchEvent ( new CustomEvent ( 'createdUser ' , {
22
+ document . dispatchEvent ( new CustomEvent ( 'createUser ' , {
23
23
detail : data
24
24
} ) ) ;
25
25
} ) ;
26
26
crud . listen ( 'createUserNew' , function ( data ) {
27
- document . dispatchEvent ( new CustomEvent ( 'createdUser ' , {
27
+ document . dispatchEvent ( new CustomEvent ( 'createUserNew ' , {
28
28
detail : data
29
29
} ) ) ;
30
30
} ) ;
@@ -64,24 +64,28 @@ const CoCreateUser = {
64
64
} ,
65
65
66
66
loginResult : function ( data ) {
67
- const { success, status, message, token } = data ;
67
+ let { success, status, message, token } = data ;
68
68
69
69
if ( success ) {
70
70
window . localStorage . setItem ( 'user_id' , data [ 'id' ] ) ;
71
71
window . localStorage . setItem ( "token" , token ) ;
72
72
document . cookie = `token=${ token } ;path=/` ;
73
73
this . getCurrentOrg ( data [ 'id' ] , data [ 'collection' ] ) ;
74
+ message = "Succesful Login" ;
74
75
}
76
+ else
77
+ message = "The email or password you entered is incorrect" ;
75
78
76
79
render . data ( {
77
80
selector : "[template_id='login']" ,
78
81
data : {
79
82
type : 'login' ,
80
- status : 'failed' ,
81
- message : 'Email or password is incorrect'
83
+ status,
84
+ message,
85
+ success
82
86
}
83
87
} ) ;
84
-
88
+
85
89
} ,
86
90
87
91
getCurrentOrg : function ( user_id , collection ) {
@@ -102,7 +106,7 @@ const CoCreateUser = {
102
106
window . localStorage . setItem ( 'adminUI_id' , data [ 'adminUI_id' ] ) ;
103
107
window . localStorage . setItem ( 'builderUI_id' , data [ 'builderUI_id' ] ) ;
104
108
105
- document . dispatchEvent ( new CustomEvent ( 'loggedIn ' ) ) ;
109
+ document . dispatchEvent ( new CustomEvent ( 'logIn ' ) ) ;
106
110
} ,
107
111
108
112
logout : ( btn ) => {
@@ -116,7 +120,7 @@ const CoCreateUser = {
116
120
new Date ( 0 ) . toUTCString ( ) ;
117
121
118
122
// Todo: replace with Custom event system
119
- document . dispatchEvent ( new CustomEvent ( 'loggedOut ' ) ) ;
123
+ document . dispatchEvent ( new CustomEvent ( 'logout ' ) ) ;
120
124
} ,
121
125
122
126
initChangeOrg : ( ) => {
@@ -300,31 +304,31 @@ export default CoCreateUser;
300
304
301
305
action . init ( {
302
306
action : "createUserNew" ,
303
- endEvent : "createdUser " ,
307
+ endEvent : "createUserNew " ,
304
308
callback : ( btn , data ) => {
305
309
CoCreateUser . createUser ( btn ) ;
306
310
} ,
307
311
} ) ;
308
312
309
313
action . init ( {
310
314
action : "createUser" ,
311
- endEvent : "createdUser " ,
315
+ endEvent : "createUser " ,
312
316
callback : ( btn , data ) => {
313
317
CoCreateUser . createUser ( btn ) ;
314
318
} ,
315
319
} ) ;
316
320
317
321
action . init ( {
318
322
action : "login" ,
319
- endEvent : "loggedIn " ,
323
+ endEvent : "login " ,
320
324
callback : ( btn , data ) => {
321
325
CoCreateUser . requestLogin ( btn , data ) ;
322
326
} ,
323
327
} ) ;
324
328
325
329
action . init ( {
326
330
action : "logout" ,
327
- endEvent : "loggedOut " ,
331
+ endEvent : "logout " ,
328
332
callback : ( btn , data ) => {
329
333
CoCreateUser . logout ( btn , data ) ;
330
334
} ,
0 commit comments