Skip to content

Commit

Permalink
mobile login not use captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhutu committed Apr 5, 2016
1 parent 6dc5b1e commit 480ddc2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
6 changes: 6 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.1.3 / 2016-04-05
==================

* 增加ismobilejs库, 移动端登录不用验证码.


1.1.2 / 2016-04-04
==================

Expand Down
Empty file added logs/development-error.log.0
Empty file.
12 changes: 12 additions & 0 deletions logs/test-error.log.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8189,"level":50,"msg":"登录密码错误 { username: '[email protected]' }","time":"2016-04-03T16:55:16.191Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8189,"level":50,"msg":"登录用户名错误 { username: '[email protected]' }","time":"2016-04-03T16:55:16.199Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8189,"level":50,"msg":"未验证用户登录 { username: '[email protected]' }","time":"2016-04-03T16:55:16.259Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8189,"level":50,"msg":"被阻止登录 { username: '[email protected]' }","time":"2016-04-03T16:55:16.314Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8281,"level":50,"msg":"登录密码错误 { username: '[email protected]' }","time":"2016-04-03T16:57:20.196Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8281,"level":50,"msg":"登录用户名错误 { username: '[email protected]' }","time":"2016-04-03T16:57:20.206Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8281,"level":50,"msg":"未验证用户登录 { username: '[email protected]' }","time":"2016-04-03T16:57:20.258Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8281,"level":50,"msg":"被阻止登录 { username: '[email protected]' }","time":"2016-04-03T16:57:20.305Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8355,"level":50,"msg":"登录密码错误 { username: '[email protected]' }","time":"2016-04-03T16:58:59.034Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8355,"level":50,"msg":"登录用户名错误 { username: '[email protected]' }","time":"2016-04-03T16:58:59.041Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8355,"level":50,"msg":"未验证用户登录 { username: '[email protected]' }","time":"2016-04-03T16:58:59.093Z","v":0}
{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":8355,"level":50,"msg":"被阻止登录 { username: '[email protected]' }","time":"2016-04-03T16:58:59.139Z","v":0}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jackblog-api-koa",
"version": "1.1.2",
"version": "1.1.3",
"description": "jackblog API koa版",
"main": "server/app.js",
"scripts": {
Expand Down Expand Up @@ -29,6 +29,7 @@
"co": "^4.6.0",
"debug": "^2.2.0",
"ioredis": "^1.15.1",
"ismobilejs": "^0.4.0",
"koa": "^1.2.0",
"koa-bodyparser": "^2.0.1",
"koa-compose": "^2.4.0",
Expand All @@ -44,9 +45,9 @@
"koa-redis": "^2.0.1",
"koa-response-time": "^1.0.2",
"koa-router": "^5.3.0",
"lodash": "^4.7.0",
"lodash": "^4.8.2",
"markdown-it": "^6.0.1",
"mongoose": "^4.4.10",
"mongoose": "^4.4.11",
"passport-github": "^1.1.0",
"passport-local": "^1.0.0",
"passport-qq": "0.0.3",
Expand Down
5 changes: 3 additions & 2 deletions server/auth/local/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
const mongoose = require('mongoose');
const router = require("koa-router")();
const passport = require('koa-passport');
const auth = require('../auth.service');
const User = mongoose.model('User');
const isMobile = require('ismobilejs');
const auth = require('../auth.service');

function checkCaptcha() {
return function *(next) {
//测试环境不用验证码
let error_msg;
if(process.env.NODE_ENV !== 'test'){
if(process.env.NODE_ENV !== 'test' && !isMobile(this.req.headers['user-agent']).any){
if(!this.request.body.captcha){
error_msg = "验证码不能为空.";
}else if(this.session.captcha !== this.request.body.captcha.toUpperCase()){
Expand Down

0 comments on commit 480ddc2

Please sign in to comment.