info-library 2.14.13-beta.1 → 2.14.13-beta.2

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.
@@ -1102,48 +1102,86 @@ class InfoAuthenticationService {
1102
1102
  }
1103
1103
  login(usuario, senha, reCaptchaToken = null, codigo2FA = null) {
1104
1104
  this.removeSessao();
1105
- return this._http
1106
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/autenticar', { Usuario: usuario, Senha: senha, ReCaptchaToken: reCaptchaToken, Codigo2FA: codigo2FA })
1105
+ return this._dataService.postNoToken(this._plataforma.LoggedUserApi, { Usuario: usuario, Senha: senha, ReCaptchaToken: reCaptchaToken, Codigo2FA: codigo2FA }, 'Autenticar')
1107
1106
  .pipe(map((r) => {
1108
- if (r.Success && r.Data != null)
1109
- this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data.Token);
1110
- return new InfoLoginModel(r.Success, r.Messages, r.Data);
1107
+ if (r.success && r.data != null)
1108
+ this._utilities.setLocalStorage(this._plataforma.TokenKey, r.data.Token);
1109
+ return r;
1111
1110
  }), catchError((e) => this.errorHandling(e)));
1111
+ // return this._http
1112
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/autenticar', { Usuario: usuario, Senha: senha, ReCaptchaToken: reCaptchaToken, Codigo2FA: codigo2FA })
1113
+ // .pipe(
1114
+ // map((r: any) => {
1115
+ // if (r.Success && r.Data != null)
1116
+ // this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data.Token);
1117
+ // return new InfoLoginModel(r.Success, r.Messages, r.Data);
1118
+ // }),
1119
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1120
+ // );
1112
1121
  }
1113
1122
  trocarEmpresa(usuario, empresaId) {
1114
- return this._http
1115
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/trocarempresa', { EmpresaId: empresaId }, { headers: this._dataService.getHeaderToken() })
1123
+ return this._dataService.post(this._plataforma.LoggedUserApi, { EmpresaId: empresaId }, 'TrocarEmpresa')
1116
1124
  .pipe(map((r) => {
1117
- if (r.Success && r.Data != null)
1118
- this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1119
- return new InfoLoginModel(r.Success, r.Messages, r.Data);
1125
+ if (r.success && r.data != null)
1126
+ this._utilities.setLocalStorage(this._plataforma.TokenKey, r.data);
1127
+ return r;
1120
1128
  }), catchError((e) => this.errorHandling(e)));
1129
+ // this._http
1130
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/trocarempresa', { EmpresaId: empresaId }, { headers: this._dataService.getHeaderToken() })
1131
+ // .pipe(
1132
+ // map((r: any) => {
1133
+ // if (r.Success && r.Data != null)
1134
+ // this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1135
+ // return new InfoLoginModel(r.Success, r.Messages, r.Data);
1136
+ // }),
1137
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1138
+ // );
1121
1139
  }
1122
1140
  trocarUnidade(usuario, empresaId, unidadeId) {
1123
- return this._http
1124
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/trocarunidade', { EmpresaId: empresaId, UnidadeId: unidadeId }, { headers: this._dataService.getHeaderToken() })
1141
+ return this._dataService.post(this._plataforma.LoggedUserApi, { EmpresaId: empresaId, UnidadeId: unidadeId }, 'TrocarUnidade')
1125
1142
  .pipe(map((r) => {
1126
- if (r.Success && r.Data != null)
1127
- this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1128
- return new InfoLoginModel(r.Success, r.Messages, r.Data);
1143
+ if (r.success && r.data != null)
1144
+ this._utilities.setLocalStorage(this._plataforma.TokenKey, r.data);
1145
+ return r;
1129
1146
  }), catchError((e) => this.errorHandling(e)));
1147
+ // return this._http
1148
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/trocarunidade', { EmpresaId: empresaId, UnidadeId: unidadeId }, { headers: this._dataService.getHeaderToken() })
1149
+ // .pipe(
1150
+ // map((r: any) => {
1151
+ // if (r.Success && r.Data != null)
1152
+ // this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1153
+ // return new InfoLoginModel(r.Success, r.Messages, r.Data);
1154
+ // }),
1155
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1156
+ // );
1130
1157
  }
1131
1158
  clonar(usuario) {
1132
- return this._http
1133
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/clonar', { Usuario: usuario }, { headers: this._dataService.getHeaderToken() })
1159
+ return this._dataService.post(this._plataforma.LoggedUserApi, { Usuario: usuario }, 'Clonar')
1134
1160
  .pipe(map((r) => {
1135
- if (r.Success && r.Data != null)
1136
- this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1137
- return new InfoLoginModel(r.Success, r.Messages, r.Data);
1161
+ if (r.success && r.data != null)
1162
+ this._utilities.setLocalStorage(this._plataforma.TokenKey, r.data);
1163
+ return r;
1138
1164
  }), catchError((e) => this.errorHandling(e)));
1165
+ // return this._http
1166
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/clonar', { Usuario: usuario }, { headers: this._dataService.getHeaderToken() })
1167
+ // .pipe(
1168
+ // map((r: any) => {
1169
+ // if (r.Success && r.Data != null)
1170
+ // this._utilities.setLocalStorage(this._plataforma.TokenKey, r.Data);
1171
+ // return new InfoLoginModel(r.Success, r.Messages, r.Data);
1172
+ // }),
1173
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1174
+ // );
1139
1175
  }
1140
1176
  logout() {
1141
1177
  if (this.isLogged()) {
1142
- this._http.post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/Logout', null, { headers: this._dataService.getHeaderToken() })
1143
- .subscribe(() => {
1178
+ this._dataService.post(this._plataforma.LoggedUserApi, 'Logout').subscribe(r => {
1144
1179
  this.removeSessao();
1145
1180
  this._router.navigateByUrl('login').then(r => { location.reload(); });
1146
1181
  });
1182
+ // this._http.post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/Logout', null, { headers: this._dataService.getHeaderToken() })
1183
+ // .subscribe(() => {
1184
+ // });
1147
1185
  }
1148
1186
  else {
1149
1187
  this.removeSessao();
@@ -1151,29 +1189,54 @@ class InfoAuthenticationService {
1151
1189
  }
1152
1190
  }
1153
1191
  getPermissions(url, logAtividade = false) {
1154
- return this._http
1155
- .get(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/getpermissao?url=' + url + '&logatividade=' + logAtividade.toString(), { headers: this._dataService.getHeaderToken() })
1156
- .pipe(map((r) => new InfoLoginModel(r.Success, r.Messages, r.Data)), catchError((e) => this.errorHandling(e)));
1192
+ return this._dataService.get(this._plataforma.LoggedUserApi, 'GetPermissao', `url=${url}&logatividade=${logAtividade.toString()}`)
1193
+ .pipe(map((r) => r), catchError((e) => this.errorHandling(e)));
1194
+ // return this._http
1195
+ // .get(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/getpermissao?url=' + url + '&logatividade=' + logAtividade.toString(), { headers: this._dataService.getHeaderToken() })
1196
+ // .pipe(
1197
+ // map((r: any) => new InfoLoginModel(r.Success, r.Messages, r.Data)),
1198
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1199
+ // );
1157
1200
  }
1158
1201
  setTrocaSenha(model) {
1159
- return this._http
1160
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/TrocarSenha', model, { headers: this._dataService.getHeaderToken() })
1161
- .pipe(map((r) => new InfoLoginModel(r.Success, r.Messages, r.Data)), catchError((e) => this.errorHandling(e)));
1202
+ return this._dataService.post(this._plataforma.LoggedUserApi, model, 'TrocarSenha')
1203
+ .pipe(map((r) => r), catchError((e) => this.errorHandling(e)));
1204
+ // return this._http
1205
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/TrocarSenha', model, { headers: this._dataService.getHeaderToken() })
1206
+ // .pipe(
1207
+ // map((r: any) => new InfoLoginModel(r.Success, r.Messages, r.Data)),
1208
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1209
+ // );
1162
1210
  }
1163
1211
  setRecuperarSenha(model) {
1164
- return this._http
1165
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/RecuperarSenha', model, { headers: this._dataService.getHeaderToken() })
1166
- .pipe(map((r) => new InfoLoginModel(r.Success, r.Messages, r.Data)), catchError((e) => this.errorHandling(e)));
1212
+ return this._dataService.post(this._plataforma.LoggedUserApi, model, 'RecuperarSenha')
1213
+ .pipe(map((r) => r), catchError((e) => this.errorHandling(e)));
1214
+ // return this._http
1215
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/RecuperarSenha', model, { headers: this._dataService.getHeaderToken() })
1216
+ // .pipe(
1217
+ // map((r: any) => new InfoLoginModel(r.Success, r.Messages, r.Data)),
1218
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1219
+ // );
1167
1220
  }
1168
1221
  setResetarSenha(model) {
1169
- return this._http
1170
- .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/ResetarSenha', model)
1171
- .pipe(map((r) => new InfoLoginModel(r.Success, r.Messages, r.Data)), catchError((e) => this.errorHandling(e)));
1222
+ return this._dataService.postNoToken(this._plataforma.LoggedUserApi, model, 'ResetarSenha')
1223
+ .pipe(map((r) => r), catchError((e) => this.errorHandling(e)));
1224
+ // return this._http
1225
+ // .post(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/ResetarSenha', model)
1226
+ // .pipe(
1227
+ // map((r: any) => new InfoLoginModel(r.Success, r.Messages, r.Data)),
1228
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1229
+ // );
1172
1230
  }
1173
1231
  getLoginResources() {
1174
- return this._http
1175
- .get(this._plataforma.Config.webapiUrl + this._plataforma.AppApi + '/GetLoginResources')
1176
- .pipe(map((r) => new InfoLoginModel(r.Success, r.Messages, r.Data)), catchError((e) => this.errorHandling(e)));
1232
+ return this._dataService.getNoToken(this._plataforma.AppApi, 'GetLoginResources')
1233
+ .pipe(map((r) => r), catchError((e) => this.errorHandling(e)));
1234
+ // return this._http
1235
+ // .get(this._plataforma.Config.webapiUrl + this._plataforma.AppApi + '/GetLoginResources')
1236
+ // .pipe(
1237
+ // map((r: any) => new InfoLoginModel(r.Success, r.Messages, r.Data)),
1238
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1239
+ // );
1177
1240
  }
1178
1241
  hasPermission(url, keyFunction = 'view') {
1179
1242
  if (url == '/' && keyFunction == 'view')
@@ -1226,9 +1289,14 @@ class InfoAuthenticationService {
1226
1289
  }
1227
1290
  }
1228
1291
  validaSessao(url) {
1229
- return this._http
1230
- .get(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/validasessao?url=' + url, { headers: this._dataService.getHeaderToken() })
1292
+ return this._dataService.get(this._plataforma.LoggedUserApi, 'ValidaSessao', `url=${url}`)
1231
1293
  .pipe(map((r) => new InfoLoginModel(r === true, '', r)), catchError((e) => this.errorHandling(e)));
1294
+ // return this._http
1295
+ // .get(this._plataforma.Config.webapiUrl + this._plataforma.LoggedUserApi + '/validasessao?url=' + url, { headers: this._dataService.getHeaderToken() })
1296
+ // .pipe(
1297
+ // map((r: any) => new InfoLoginModel(r === true, '', r)),
1298
+ // catchError((e: HttpErrorResponse) => this.errorHandling(e))
1299
+ // );
1232
1300
  }
1233
1301
  removeSessao() {
1234
1302
  Object.keys(localStorage).forEach((key) => {