Jump to content

marcus

Members
  • Posts

    289
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by marcus

  1. I see this approach is also loosely based on my GitHub Login "fork" of apeisas FB module :)

    Can you debug what is returned from...

         $ghUserData = json_decode(file_get_contents($access_url, false, $context));
    

    ...and if $ghUserData contains the Google Mail address in the first place? That was the approach, to get a value (above its the GitHub Id) from the JSON and persist it on a certain user as a field value. Theoretically this should work as well with the email, which would then become $u->email.

    Also, this...

    // Add stream context
    			$options  = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
    			$context  = stream_context_create($options);
    

    ...was somehow necessary for GH, but not in apeisas original module.

    It's quite interesting how often apeisas module appeared here lately. Screams for a generic OAuth2 module, doesn't it? :)

    // edit:

    It seems that the "grabs first user, changes their password, logs them in" phenomenon has its cause here:

    public function processLogin($ghUserData) {
            $id = $ghUserData->id; // (1)
            $u = $this->users->get("google_id=$id"); // (2)
    
            // First we create random pass to use in login
            $uniqid = uniqid();
            $pass = sha1($uniqid . $id . $ghUserData->updated_at);
    
            // User has logged in earlier with Google id, great news let's login
            if ($u->id) { // (3)
                $u->of(false);
                $u->pass = $pass; // (4)
                $u->addRole(self::name);
                $u->save();
            }

    Assumptions:

    (1) is empty/null

    (2) possibly translates as ->get() = ->first(), so returns first user

    (3) this is true, but the wrong user id

    (4) overwrite first users password

    // edit2:

    Your thread got me tweaking my GitHub Login module a little bit. I learned that I can only retrieve the (GitHub) user's email if its set to 'public'. Maybe thats similar in Google's API - either you aren't able to get the email at all, or it has to explicitly set as public. However, I think you have to solve said "phnomenon" first.

    • Like 2
  2. So, let's launch this finally!

    › https://processwire-recipes.com/ ‹

    As you can see, it's a work in progress. The design is going to change, Nico at the helm, and once we got a "critical mass" of recipes, another way of structuring recipes (the "table of contents") will also go online.

    To contribute, you can post your recipes either in this thread and we'll pick it up, or - codey - via Pull Request on GitHub of this repo here. Frankly, that's the favoured way, simple and a good start dive in to GitHub and this form of Open Source contribution.

    As always, feedback (and of course, contribution) is really welcome. :) We're always eager to learn - and helping to learn new stuff and create a place to spread some PW knowledge, that's what PWR was about in the first place :)

    Big big thanks to my partner in crime owzim who, among other things, contributed the - imho - heart of this tiny project: a textfile-to-page-importer. Finding an elegant way to contribute was one of the reasons this took so long, and during Beyond Tellerrand conference, it finally clicked into place.

    • Like 20
  3. Thanks for the heads up regarding module versioning. I learned that the modules not showing up as being updated have one thing in common: Version numbers below 1.0.0 (like for example, my FlagPages module). I just installed FlagPages on a PW 2.5.10 system, and though its version is set as 022 (0.2.2) ProcessWire somehow understands it as 0.1.8 and offers an update to 0.2.2. I'll test FP's ability to run under 2.5+ (it totally should), and will then bump both version number and compatible PW version.

    • Like 1
  4. We plan to launch in a few days. If you'd like to help us having a proper starter set of recipes, please contribute via adding to this GitHub repo: https://github.com/processwire-recipes/ProcessWireRecipes (the recipe files themselves can be found at /site/recipe-txt-files)

    Recipe files are plain text files written in markdown (here is an example of their intended structure). Owzim's awesome RecipeInstaller module makes it possible to easily convert them into ProcessWire pages. 

    edit: recipe txt files will be outsourced in a separate repo to simplify things, here is said repo: https://github.com/processwire-recipes/Recipes

    • Like 2
  5. No necessity for a module in this case. Use field type "Page" instead.

    In your tree in the ProcessWire admin, add a (hidden, if you want) page called, for example "Currencies". Afterwards add children to them: e.g. USD, EUR, GBP.

    Next step: create a field of type "Page" (this will reference pages), limit it to a single value ("Details" tab in the fields properties). On tab "Input", set the "Parent of selectable pages" to the aforementioned, newly created "Currencies" site.

    Now you got the functionality you're aiming for. This "page field" can now be assigned to another template.

    Advantage of this approach: When you need to add options (a new currency) to your set of currencies, you can just add a page and all the "page field selects" implemented elsewhere will notice that there's a new option.

    If this description is too quick and shallow, just give a notice. 

    This whole approach is one of ProcessWire's strength and I'd be happy to explain it in more detail :)

    • Like 2
×
×
  • Create New...