@fluxhub/fluxhub-lib 10.0.126 → 10.0.127

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.
@@ -3786,6 +3786,53 @@
3786
3786
  throw err;
3787
3787
  }));
3788
3788
  };
3789
+ AuthenticationService.prototype.login_by_email = function (email, displayError) {
3790
+ var _this = this;
3791
+ if (displayError === void 0) { displayError = true; }
3792
+ this.url = this.app_s.API_ENDPOINT + this.app_s.LOGIN_ENDPOINT + '_email';
3793
+ var post_v = JSON.stringify({ email: email });
3794
+ if (this.app_s.LDAP_AUTH == 1)
3795
+ post_v = JSON.stringify({
3796
+ email: email
3797
+ });
3798
+ return this.http
3799
+ .post(this.url, post_v, {
3800
+ headers: this.headers,
3801
+ })
3802
+ .pipe(operators.map(function (res) {
3803
+ // Handle errors, display if enabled
3804
+ var err;
3805
+ if (!res) {
3806
+ err = new Error("Empty server response");
3807
+ }
3808
+ else if (res.result_msg === "KO") {
3809
+ err = new Error(res.msg);
3810
+ }
3811
+ else {
3812
+ if (res.result_data.length > 0) {
3813
+ localStorage.setItem(_this.app_s.COMPANY_KEY + "token", res.result_data[0].token);
3814
+ }
3815
+ }
3816
+ if (err) {
3817
+ console.error(err);
3818
+ if (displayError) {
3819
+ _this.toastr.error(err.message);
3820
+ }
3821
+ throw new Error(err);
3822
+ }
3823
+ return res || new QGResult();
3824
+ }), operators.catchError(function (err) {
3825
+ // In a real world app, we might use a remote logging infrastructure
3826
+ // We'd also dig deeper into the error to get a better message
3827
+ var errMsg = err.message
3828
+ ? err.message
3829
+ : err.status
3830
+ ? err.status + " - " + err.statusText
3831
+ : "Server error";
3832
+ console.error(errMsg); // log to console instead
3833
+ throw err;
3834
+ }));
3835
+ };
3789
3836
  AuthenticationService.prototype.get_user_info = function (username, displayError) {
3790
3837
  var _this = this;
3791
3838
  if (displayError === void 0) { displayError = true; }