Projet

Général

Profil

Télécharger (1,29 ko) Statistiques
| Branche: | Tag: | Révision:

mandayejs / mandayejs / mandaye / static / force.redirect.js @ 90a003cc

1
/* This scripts force the redirection to the homepage
2
 * if current pathname == <mandaye_redirect_url> and the current user is
3
 * already associated and currently connected
4
 */
5

    
6
$(function(){
7

    
8
    var mandaye_post_login = '/_mandaye/post-login'
9

    
10
    function urlExists(elt, url){
11
        var found = false;
12
        $(elt).find('a').each(function(){
13
            found = this.href.indexOf(url);
14
        });
15
        if (found != -1)
16
           return true;
17
       return false;
18
    }
19

    
20
    function conditionsOk(){
21
        if (!urlExists('#mandaye-logon-url', '/_mandaye/accounts/mellon/logout')){
22
            return false;
23
        }
24

    
25
        if(!urlExists('#mandaye-association-url', '/_mandaye/dissociate')){
26
            return false;
27
        }
28

    
29
        /* Forces mandayejs authentication through pathname
30
         */
31
        if(mandaye_redirect_url.length){
32
            if (window.location.href.indexOf(mandaye_redirect_url) < 1){
33
                return false;
34
            }
35

    
36
        }
37
        /* Forces mandayejs authentication through a specific locator
38
        */
39
        if(mandaye_redirect_locator.length){
40
            if (!$(mandaye_redirect_locator).length){
41
                return false;
42
            }
43
        }
44
        return true;
45
    }
46

    
47
    if(conditionsOk())
48
        window.location = mandaye_post_login ;
49

    
50
});
(1-1/5)