diff --git a/app/scripts/app.ts b/app/scripts/app.ts
index f39b52591..9937f57e5 100755
--- a/app/scripts/app.ts
+++ b/app/scripts/app.ts
@@ -152,6 +152,8 @@ function appRun(gettextCatalog: any,
});
});
+ UserService.login();
+
ProjectsService.getProjects({
size: 100
})
diff --git a/app/scripts/components/user/user.services.ts b/app/scripts/components/user/user.services.ts
index 160303309..f9ef5fa4b 100755
--- a/app/scripts/components/user/user.services.ts
+++ b/app/scripts/components/user/user.services.ts
@@ -19,6 +19,7 @@ module ngApp.components.user.services {
class UserService implements IUserService {
currentUser: IUser;
+ isFetching: boolean = false;
/* @ngInject */
constructor(private AuthRestangular: restangular.IService,
@@ -48,29 +49,33 @@ module ngApp.components.user.services {
}
login(): void {
- this.AuthRestangular.all("user")
- .withHttpConfig({
- withCredentials: true
- })
- .post({}, {})
- .then((data) => {
- data.isFiltered = true;
- this.setUser(data);
- }, (response) => {
- if(response.status === 401) {
- if (this.currentUser) {
- this.currentUser = undefined;
- this.notify({
- message: "",
- messageTemplate: "Session expired or unauthorized.",
- container: "#notification",
- classes: "alert-warning"
- });
+ if (!this.isFetching) {
+ this.isFetching = true;
+ this.AuthRestangular.all("user")
+ .withHttpConfig({
+ withCredentials: true
+ })
+ .post({}, {})
+ .then((data) => {
+ data.isFiltered = true;
+ this.setUser(data);
+ }, (response) => {
+ if(response.status === 401) {
+ if (this.currentUser) {
+ this.currentUser = undefined;
+ this.notify({
+ message: "",
+ messageTemplate: "Session expired or unauthorized.",
+ container: "#notification",
+ classes: "alert-warning"
+ });
+ }
+ } else {
+ this.$log.error("Error logging in, response status " + response.status);
}
- } else {
- this.$log.error("Error logging in, response status " + response.status);
- }
- });
+ })
+ .finally(() => this.isFetching = false);
+ }
}
getToken(): void {