Menu Problem for 2 different user


#1

Hi developers,
i have a problem with my Menu in my case :
i have 2 different user with 2 different menu and when i logout from the first user account and change to the second user account i found the old menu ( menu of the first user) still loaded for the second !

i ll be so gratefull if any one help


#2

will be nice to see some code


#3

@avishai_peretz_dev this is my app.component.ts

    constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, public menu: MenuController) {
        this.initializeApp();

        // used for an example of ngFor and navigation
        this.appMenuItems = [
            {title: 'Accueil', component: HomePage, icon: "md-home"},
            {title: 'Stages', component: stagesPage, icon: "md-attach"},
            {title: 'Nouveaux article', component: ETarticlePage, icon: "md-create"},
            {title: 'Mes Articles', component: mesarticlePage, icon: "md-list-box"},
            {title: 'Annonce', component: ETpubPage, icon: "md-clipboard"},
            {title: 'Historique', component: EThistoriquePage, icon: "ios-undo"},
            {title: 'Stage en cours', component: authPage, icon: "md-alarm"},
            {title: 'A propos', component: exemplePage, icon: 'information-circle'},

        ];


        this.helpMenuItems = [

            //{title: 'Nouveaux Annonces', component: NouveauxPubPage, icon: 'md-create'},
            {title: 'Nouveaux Annonces', component: NouveauxPubPage, icon: 'md-create'},
            {title: 'Mes Annonces', component: HomeePage, icon: 'md-list-box'},
            {title: 'Mes Etudiant', component: EtudiantPage, icon: 'ios-contacts'},
            {title: 'Historique', component: HistoriquePage, icon: 'ios-undo'},
            {title: 'A propos', component: aproposPage, icon: 'information-circle'},
        ];

    }

    initializeApp() {
        this.platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            this.type = localStorage.getItem('type');
            console.log(this.type)
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });
    }

    openPage(page) {
        // Reset the content nav to have just this page
        // we wouldn't want the back button to show in this scenario
        this.nav.setRoot(page.component);
    }

    deconnexionetudiant() {
        localStorage.removeItem('cin');
        localStorage.removeItem('type');
        this.nav.setRoot(authPage);
    }

    deconnexion() {
        localStorage.removeItem('id_en');
        localStorage.removeItem('type');
        this.nav.setRoot(authPage);
    }


#4

Hi
I hope this can help you:


#5

i already did this but in the login page , sry this didn’t help me


#6

Your “initializeApp” function will run once the app is loaded and never again.
You need to call this function after user doing login.
so first keep the menus arrays in shared provider and call to function after login that select what menu is selected


#7

this is my initializeApp
it didn’t work too



    initializeApp() {
        this.platform.ready().then(() => {
            // Okay, so the platform is ready and our plugins are available.
            // Here you can do any higher level native things you might need.
            this.type = localStorage.getItem('type');
            console.log(this.type)
            this.statusBar.styleDefault();
            this.splashScreen.hide();
        });
    }

    deconnexionetudiant(){
        localStorage.removeItem('cin');
        localStorage.removeItem('type');
        this.initializeApp();
        this.nav.setRoot(authPage);
    }
    deconnexion(){
        localStorage.removeItem('id_en');
        localStorage.removeItem('type');
        this.initializeApp();
        this.nav.setRoot(authPage);
    }