Monthly Archives: July 2017

passport.js with node.js to do Local Authentication

The whole example could be found in:
https://github.com/emacslisp/angular2/tree/meteor/passport-local

prerequisites

1. create an empty folder for project, say ‘passport-local’

1
2
3
4
5
6
7
npm init
npm install passport --save
npm install passport-local --save
npm install jade --save
npm install mongodb --save
npm install mongoose --save
npm install passport-local-mongoose --save

2. install mongodb and run
$ mongod

3. create an app.js

1
2
3
4
5
6
7
 
var path = require('path');
var express = require('express');
var http = require('http');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;

for more details check github project.

4. ‘node app’ to run the example

5. register user firstly, you will see ‘Account’ doc has been created with username, password and salt.

6. try to login to get session.

WordPress – analysis wp_admin_css(‘install’,true);

as we know css is key role for web page,

wordpress using wp_admin_css(‘install’, true); to print link css.
in format of <link href=’…/xxx.css’>

the most important statement.

1
$tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle, $href, $media);

“<link rel=’$rel’ id=’$handle-css’ $title href=’$href’ type=’text/css’ media=’$media’ />\n” will be replaced
to be ‘<link rel=’stylesheet’ id=’install-css’ href=’http://localhost:8082/wordpress2/wp-admin/css/install.min.css?ver=4.7.2′ type=’text/css’ media=’all’ />

Let’s look at what define of apply_filters, “apply_filters($tag,$value)”. ‘style_loader_tag’ has nothing in global variable $wp_filter.

Therefore, apply_filters do nothing here, it only return second param as string to print.

1
2
3
4
echo $conditional_pre;
echo $tag;
$this->print_inline_style( $handle );
echo $conditional_post;