Changeset 2007

Show
Ignore:
Timestamp:
08/15/08 13:43:16 (5 months ago)
Author:
psychcf
Message:

Worked on the xsite portion of ticket #110

Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • branches/1.0/backend/api/xsite.php

    r1864 r2007  
    1010require("../lib/includes.php"); 
    1111import("models.user"); 
     12import("models.auth"); 
    1213import("lib.Json.Json"); 
    1314$user = $User->get_current(); 
     
    2425        $p->setMethod(HTTP_REQUEST_METHOD_GET); 
    2526        if(isset($params["authinfo"])) { 
    26                 $p->addHeader('Authorization', 'Basic ' . $params["authinfo"]); 
     27                $auth = $params["authinfo"]; 
     28                $server = array(); 
     29                preg_match('(^(?:[^/]+://)?([^/:]+))', $url, $server); 
     30                if(array_key_exists($auth, "password")) { 
     31                        //create/update the entry in the DB 
     32                        $entries = $Auth->filter(array( 
     33                                appid => $params["appid"], 
     34                                server => $server[1], 
     35                                username => $auth["username"], 
     36                                userid => $user->id 
     37                        )); 
     38                        if(!$entries) 
     39                        { 
     40                                //create 
     41                                $entry = new $Auth(array( 
     42                                        appid => $params["appid"], 
     43                                        server => $server[1], 
     44                                        username => $auth["username"], 
     45                                        userid => $user->id, 
     46                                        password => $auth["password"], 
     47                                )); 
     48                        } 
     49                        else { 
     50                                //update 
     51                                $entry = $entries[0]; 
     52                                $entry->password = $auth["password"]; 
     53                        } 
     54                        $entry->save(); 
     55                } 
     56                else { 
     57                        //fetch password from the db 
     58                        $entries = $Auth->filter(array( 
     59                                appid => $params["appid"], 
     60                                server => $server[1], 
     61                                username => $auth["username"], 
     62                                userid => $user->id 
     63                        )); 
     64                        $entry = $entries[0]; 
     65                        $auth["password"] = $entry->password; 
     66                } 
     67                $p->addHeader('Authorization', 'Basic ' . base64_encode($auth["username"].":".$auth["password"])); 
    2768        } 
    2869        //      required for some ajax apis 
  • branches/1.0/desktop/dojotoolkit/api/_base.js

    r1948 r2007  
    1010dojo.require("api.ui"); 
    1111dojo.require("api.Window"); 
    12 dojo.require("dojox.encoding.base64"); 
    1312 
    1413api.xhr = function(/*dojo.__ioArgs|String*/args) { 
     
    4342                } 
    4443                if(args.auth) { 
    45                         var b = []; 
    46                         var s = args.auth.username + ":" + args.auth.password; 
    47                         for(var i = 0; i < s.length; ++i){ 
    48                                 b.push(s.charCodeAt(i)); 
    49                         } 
    50                         xsiteArgs.authinfo = dojox.encoding.base64.encode(b); 
     44                        xsiteArgs.authinfo = dojo.clone(args.auth); 
    5145                } 
    5246                args.content["DESKTOP_XSITE_PARAMS"] = dojo.toJson(xsiteArgs); 
  • branches/1.0/desktop/dojotoolkit/desktop/ui/applets/Twitter.js

    r1934 r2007  
    44dojo.require("dijit.Dialog"); 
    55dojo.require("dijit.form.Textarea"); 
    6 dojo.require("dojox.encoding.crypto.Blowfish"); 
    76dojo.require("dojox.validate.web"); 
    87dojo.requireLocalization("desktop.ui", "accountInfo"); 
     
    2221        }, 
    2322        startup: function() { 
    24                 if(!this.settings.key) 
    25                         this.settings.key = dojox.encoding.crypto.Blowfish.encrypt(Math.random(), Math.random()); 
    2623                if(!this.settings.username) 
    2724                        this.drawLoginForm(); 
     
    7471                else { 
    7572                        var authInfo = { 
    76                                 username: dojox.encoding.crypto.Blowfish.decrypt(this.settings.username, this.settings.key), 
    77                                 password: dojox.encoding.crypto.Blowfish.decrypt(this.settings.password, this.settings.key) 
     73                                username: this.settings.username 
    7874                        } 
    7975                } 
     
    9187                if(!this.settings.username) { 
    9288                        this.settings = dojo.mixin(this.settings, { 
    93                                 username: dojox.encoding.crypto.Blowfish.encrypt(this.loginUi.username.getValue(), this.settings.key), 
    94                                 password: dojox.encoding.crypto.Blowfish.encrypt(this.loginUi.password.getValue(), this.settings.key) 
     89                                username: this.loginUi.username.getValue() 
    9590                        }); 
    9691                        this.loginUi.username.setValue(""); 
     
    193188                        }, 
    194189                        auth: { 
    195                                 username: dojox.encoding.crypto.Blowfish.decrypt(this.settings.username, this.settings.key), 
    196                                 password: dojox.encoding.crypto.Blowfish.decrypt(this.settings.password, this.settings.key) 
     190                                username: this.settings.username, 
    197191                        }, 
    198192                        load: dojo.hitch(this, function() { 
  • trunk/desktop/dojotoolkit/api/_base.js

    r1991 r2007  
    11dojo.provide("api._base"); 
    22 
     3dojo.require("api.flash.flash"); 
    34dojo.require("api.Console"); 
    45dojo.require("api.crosstalk"); 
    56dojo.require("api.Filearea"); 
    67dojo.require("api.filesystem"); 
    7 dojo.require("api.Mail"); 
    88dojo.require("api.Registry"); 
    99dojo.require("api.Sound"); 
    1010dojo.require("api.ui"); 
    1111dojo.require("api.Window"); 
    12 dojo.require("dojox.encoding.base64"); 
    1312 
    1413api.xhr = function(/*dojo.__ioArgs|String*/args) { 
     
    4342                } 
    4443                if(args.auth) { 
    45                         var b = []; 
    46                         var s = args.auth.username + ":" + args.auth.password; 
    47                         for(var i = 0; i < s.length; ++i){ 
    48                                 b.push(s.charCodeAt(i)); 
    49                         } 
    50                         xsiteArgs.authinfo = dojox.encoding.base64.encode(b); 
     44                        xsiteArgs.authinfo = dojo.clone(args.auth); 
    5145                } 
    5246                args.content["DESKTOP_XSITE_PARAMS"] = dojo.toJson(xsiteArgs); 
  • trunk/desktop/dojotoolkit/desktop/ui/applets/Twitter.js

    r1934 r2007  
    44dojo.require("dijit.Dialog"); 
    55dojo.require("dijit.form.Textarea"); 
    6 dojo.require("dojox.encoding.crypto.Blowfish"); 
    76dojo.require("dojox.validate.web"); 
    87dojo.requireLocalization("desktop.ui", "accountInfo"); 
     
    2221        }, 
    2322        startup: function() { 
    24                 if(!this.settings.key) 
    25                         this.settings.key = dojox.encoding.crypto.Blowfish.encrypt(Math.random(), Math.random()); 
    2623                if(!this.settings.username) 
    2724                        this.drawLoginForm(); 
     
    7471                else { 
    7572                        var authInfo = { 
    76                                 username: dojox.encoding.crypto.Blowfish.decrypt(this.settings.username, this.settings.key), 
    77                                 password: dojox.encoding.crypto.Blowfish.decrypt(this.settings.password, this.settings.key) 
     73                                username: this.settings.username 
    7874                        } 
    7975                } 
     
    9187                if(!this.settings.username) { 
    9288                        this.settings = dojo.mixin(this.settings, { 
    93                                 username: dojox.encoding.crypto.Blowfish.encrypt(this.loginUi.username.getValue(), this.settings.key), 
    94                                 password: dojox.encoding.crypto.Blowfish.encrypt(this.loginUi.password.getValue(), this.settings.key) 
     89                                username: this.loginUi.username.getValue() 
    9590                        }); 
    9691                        this.loginUi.username.setValue(""); 
     
    193188                        }, 
    194189                        auth: { 
    195                                 username: dojox.encoding.crypto.Blowfish.decrypt(this.settings.username, this.settings.key), 
    196                                 password: dojox.encoding.crypto.Blowfish.decrypt(this.settings.password, this.settings.key) 
     190                                username: this.settings.username, 
    197191                        }, 
    198192                        load: dojo.hitch(this, function() { 
  • website/trunk/desktopsite/apps/repository/models.py

    r2000 r2007  
    1515     
    1616class Version(models.Model): 
    17     package = models.FireignKey(Package) 
     17    package = models.ForeignKey(Package) 
    1818    creation_date = models.DateField(auto_now=True, editable=False) 
    1919    name = models.CharField(max_length=100)