Просмотр исходного кода

Merge pull request #27 from crowi/v1.1.2

V1.1.2
Sotaro KARASAWA 11 лет назад
Родитель
Сommit
4809247faf
11 измененных файлов с 33 добавлено и 129 удалено
  1. 10 0
      CHANGES.md
  2. 1 1
      README.md
  3. 1 1
      bower.json
  4. 0 111
      doc/01-install-and-config.md
  5. 0 1
      doc/02-developer-reference.md
  6. 0 5
      doc/index.md
  7. 1 1
      lib/form/register.js
  8. 16 4
      lib/routes/login.js
  9. 3 3
      lib/util/googleAuth.js
  10. 0 1
      lib/util/middlewares.js
  11. 1 1
      package.json

+ 10 - 0
CHANGES.md

@@ -1,6 +1,16 @@
 CHANGES
 ========
 
+## 1.1.2
+
+* Feature: Add one-click button to create today's memo on  header (Thanks @fivestar).
+* Fix: Fixize version of dependent libraries. (Thanks @shinnya)
+* Fix: Google Project OAuth is working now (Thanks @yudoufu).
+* Fix: Disabled auto-highlight because of the slow of the language detection.
+* Change: Now `.` included `username` are allowed.
+* Remove documentation from this repository. See [GitHub Wiki](https://github.com/crowi/crowi/wiki) instead. (Thanks @shinnya)
+* And some fixes. (Thank you: @suzuki @yudoufu @fivestar @shinnya)
+
 ## 1.1.1
 
 * Fix: Error on accessing restricted page.

+ 1 - 1
README.md

@@ -22,7 +22,7 @@ Install dependencies and build CSS and JavaScript:
 
     $ npm install
 
-More info are [here](doc/index.md).
+More info are [here](https://github.com/crowi/crowi/wiki/Install-and-Configuration).
 
 
 Dependencies

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "crowi",
-  "version": "1.1.1",
+  "version": "1.1.2",
   "description": "Crocos' Wiki implementation in node.js",
   "authors": [
     "Sotaro KARASAWA <sotarok@crocos.co.jp>",

+ 0 - 111
doc/01-install-and-config.md

@@ -1,111 +0,0 @@
-# Install and Configuration
-
-## Install
-
-To install, just set up dependencies after clone.
-
-    $ npm install .
-    $ git submodule update --init
-
-
-## Copy Configuration File
-
-First, copy `.dist` file to the own config file.
-
-    $ cp config/default.js.dist config/default.js
-
-
-## Configuration List
-
-Here is an original distributed configuration.
-
-```
-{
-  server: {
-    port: 3000
-  },
-  app: {
-    title: 'Crocos Wiki'
-  },
-  security: {
-    confidential: '',
-    passwordSeed: "j9a5gt", // please change here
-    registrationWhiteList: [
-    ]
-  },
-  aws: {
-    bucket: 'crowi',
-    region: 'ap-northeast-1',
-    accessKeyId: '',
-    secretAccessKey: ''
-  },
-  mongodb: {
-    host: 'localhost',
-    dbname: 'crowi',
-    user: '',
-    password: ''
-  },
-  searcher: {
-    url: 'https:// ...' // crocos-wikis
-  },
-  google: {
-    clientId: '',
-    clientSecret: ''
-  },
-  facebook: {
-    appId: '',
-    secret: ''
-  },
-  session: {
-    secret: 'please input here some string',
-  }
-}
-```
-
-## Set Up Facebook Application
-
-to be writte.
-
-
-## Set Up Google Project
-
-Enable configuration of Google, you can register and login by using google account.
-Configure `google` section,
-
-Registration/Login using Google account is also affected a whilelist setting on `security` section. You can restrict registrant's email by only listed emails. This setting is useful if you use Google Apps on your organization.
-
-
-For more help, go to the official document.
-[Google Developers Console Help](https://developers.google.com/console/help/new/#generatingoauth2)
-
-### Create Project
-
-To set up your project's consent screen, do the following:
-
-1. Go to the [Google Developers Console](https://console.developers.google.com/project).
-2. Select **Create Project**.
-3. Fill forms and click **Create**.
-
-
-### Create New Client ID
-
-In the sidebar on the left, select Credentials, then select **Create New Client ID**.
-
-1. Select **Web Application**
-2. Fill forms as below:
-
-   If you set up this wiki on `wiki.example.com`, fill the as below:
-
-       https://wiki.example.com
-
-   And fill 'Redirect URL' field as below:
-
-       https://wiki.example.com/google/callback
-
-
-So, now you can get **Client ID** and **Client Secret**, copy these values and paste it on `config/default.js`.
-
-### Set Up Consent Screen
-
-Make sure that the email is set on **EMAIL ADDRESSS** field.
-

+ 0 - 1
doc/02-developer-reference.md

@@ -1 +0,0 @@
-# Developer Reference

+ 0 - 5
doc/index.md

@@ -1,5 +0,0 @@
-# Documentation
-
-* [Install and Configuration](01-install-and-config.md)
-* [Developer Reference](02-developer-reference.md)
-

+ 1 - 1
lib/form/register.js

@@ -4,7 +4,7 @@ var form = require('express-form')
   , field = form.field;
 
 module.exports = form(
-  field('registerForm.username').required().is(/^[\da-zA-Z\-_]+$/),
+  field('registerForm.username').required().is(/^[\da-zA-Z\-_\.]+$/),
   field('registerForm.name').required(),
   field('registerForm.email').required(),
   field('registerForm.password').required().is(/^[\da-zA-Z@#$%-_&\+\*\?]{6,64}$/),

+ 16 - 4
lib/routes/login.js

@@ -37,6 +37,8 @@ module.exports = function(app) {
     var nextAction = req.session.googleCallbackAction || '/login';
     debug('googleCallback.nextAction', nextAction);
     req.session.googleAuthCode = req.query.code || '';
+    debug('google auth code', req.query.code);
+
 
     return res.redirect(nextAction);
   };
@@ -133,7 +135,6 @@ module.exports = function(app) {
   };
 
   actions.register = function(req, res) {
-    var registerForm = req.form.registerForm || {};
     var googleAuth = require('../util/googleAuth')(app);
 
     // ログイン済みならさようなら
@@ -147,6 +148,8 @@ module.exports = function(app) {
     }
 
     if (req.method == 'POST' && req.form.isValid) {
+      var registerForm = req.form.registerForm || {};
+
       var name = registerForm.name;
       var username = registerForm.username;
       var email = registerForm.email;
@@ -229,22 +232,29 @@ module.exports = function(app) {
     } else { // method GET
       // google callback を受ける可能性もある
       var code = req.session.googleAuthCode || null;
+      var googleId = req.session.googleId || null;
+      var googleEmail = req.session.googleEmail || null;
 
       debug('register. if code', code);
+      // callback 経由で reigster にアクセスしてきた時最初だけこの if に入る
+      // code から email などを取得したらそれを session にいれて code は消去
       if (code) {
         googleAuth.handleCallback(req, function(err, tokenInfo) {
+          debug('tokenInfo', tokenInfo);
+          req.session.googleAuthCode = null;
+
           if (err) {
             req.flash('registerWarningMessage', 'Googleコネクト中にエラーが発生しました。');
             return res.redirect('/login?register=1'); // TODO Handling
           }
 
-          var googleId = tokenInfo.user_id;
-          var googleEmail = tokenInfo.email;
+          req.session.googleId = googleId = tokenInfo.user_id;
+          req.session.googleEmail = googleEmail = tokenInfo.email;
+
           if (!User.isEmailValid(googleEmail)) {
             req.flash('registerWarningMessage', 'このメールアドレスのGoogleアカウントはコネクトできません。');
             return res.redirect('/login?register=1');
           }
-
           return res.render('login', {
             googleId: googleId,
             googleEmail: googleEmail,
@@ -252,6 +262,8 @@ module.exports = function(app) {
         });
       } else {
         return res.render('login', {
+          googleId: googleId,
+          googleEmail: googleEmail,
         });
       }
     }

+ 3 - 3
lib/util/googleAuth.js

@@ -20,7 +20,7 @@ module.exports = function(app) {
   }
 
   lib.createAuthUrl = function(req, callback) {
-    var callbackUrl = req.baseUrl + '/google/callback';
+    var callbackUrl = config.crowi['app:url'] + '/google/callback';
     var google = createOauth2Client(callbackUrl);
 
     var redirectUrl = google.generateAuthUrl({
@@ -32,7 +32,7 @@ module.exports = function(app) {
   };
 
   lib.handleCallback = function(req, callback) {
-    var callbackUrl = req.baseUrl + '/google/callback';
+    var callbackUrl = config.crowi['app:url'] + '/google/callback';
     var google = createOauth2Client(callbackUrl);
     var code = req.session.googleAuthCode || null;
 
@@ -45,7 +45,7 @@ module.exports = function(app) {
         return callback(new Error('[googleAuth.handleCallback] Error to get token.'), null);
       }
 
-      googleapis.discover('oauth2', 'v1').withOpts({cache: { path: __dirname + '/../tmp/googlecache'}}).execute(function(err, client) {
+      googleapis.discover('oauth2', 'v1').withOpts({cache: { path: __dirname + '/../../tmp/googlecache'}}).execute(function(err, client) {
         if (err) {
           return callback(new Error('[googleAuth.handleCallback] Failed to discover oauth2 API endpoint.'), null);
         }

+ 0 - 1
lib/util/middlewares.js

@@ -118,7 +118,6 @@ exports.applicationNotInstalled = function() {
 exports.applicationInstalled = function() {
   return function(req, res, next) {
     var config = req.config;
-    console.log(config);
 
     if (Object.keys(config.crowi).length === 1) { // app:url is set by process
       return res.redirect('/installer');

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "crowi",
-  "version": "1.1.1",
+  "version": "1.1.2",
   "description": "The simple & powerful Wiki",
   "tags": [
     "wiki",