feat(users): set user status to idle when long time not login

This commit is contained in:
OldHawk
2017-12-03 16:50:22 +08:00
parent ced86df811
commit 11f5f2bfec
7 changed files with 67 additions and 6 deletions

View File

@@ -226,6 +226,8 @@
SENDING_MAIL: 'The authentication mail is being sent. Please wait a moment...',
SIGNIN_ERROR: 'Signin Error!',
SIGNUP_ERROR: 'Signup Error!',
SIGNIN_WELCOME_NORMAL: 'Welcome, {{name}}',
SIGNIN_WELCOME_IDLE: 'Welcome, {{name}}, you not login for long time, your account is IDLE status, before download any things, you should active you account again in profile menu "account status"!',
NEW_PASSWORD: 'New Password',
NP_REQUIRED: 'Enter a new password.',
@@ -659,6 +661,8 @@
STATUS: 'Status',
NORMAL: 'normal',
BANNED: 'banned',
IDLE: 'idle',
ACTIVE: 'Active',
INACTIVE: 'inactive',
BTN_BAN: 'Ban',
BTN_UNBAN: 'Unban',
@@ -1224,7 +1228,10 @@
INVALID_USERNAME: 'Invalid username!',
INVALID_PASSWORD: 'Invalid password!',
YOU_ARE_BANNED: 'You are banned from the server!',
ACCOUNT_IS_NOT_ACTIVATED: 'Your account is not activated, you should active first!'
ACCOUNT_IS_NOT_ACTIVATED: 'Your account is not activated, you should active first!',
ONLY_VIP_CAN_DOWNLOAD: 'This torrent is only for Vip users',
CAN_NOT_DOWNLOAD_BANNED: 'Download failed, you are banned from server',
CAN_NOT_DOWNLOAD_IDLE: 'Download failed, you are idle for long time, before download any things, you should active you account again in profile menu "account status"!'
}
};

View File

@@ -226,6 +226,8 @@
SENDING_MAIL: '正在发送验证邮件,请稍等...',
SIGNIN_ERROR: '登录失败!',
SIGNUP_ERROR: '注册失败!',
SIGNIN_WELCOME_NORMAL: '欢迎您, {{name}}',
SIGNIN_WELCOME_IDLE: '欢迎您, {{name}}, 您已经很长时间没有你登录, 帐户处于空闲状态, 在您下载任何种子前, 您必须进入帐户状态页再次激活您的帐户!',
NEW_PASSWORD: '新密码',
NP_REQUIRED: '新密码不能为空.',
@@ -659,6 +661,8 @@
STATUS: '帐号状态',
NORMAL: '正常',
BANNED: '被禁止',
IDLE: '空闲',
ACTIVE: '激活',
INACTIVE: '未激活',
BTN_BAN: '禁止',
BTN_UNBAN: '解禁',
@@ -1224,7 +1228,10 @@
INVALID_USERNAME: '无效的用户名!',
INVALID_PASSWORD: '无效的密码!',
YOU_ARE_BANNED: '您已被服务器禁止(banned)!',
ACCOUNT_IS_NOT_ACTIVATED: '您的帐户未激活, 请激活后再试!'
ACCOUNT_IS_NOT_ACTIVATED: '您的帐户未激活, 请激活后再试!',
ONLY_VIP_CAN_DOWNLOAD: '该种子只有VIP用户才可以下载',
CAN_NOT_DOWNLOAD_BANNED: '下载失败, 您被服务器禁止(banned)',
CAN_NOT_DOWNLOAD_IDLE: '下载失败,您闲置了太长时间,在您下载任何种子前, 您必须进入帐户状态页再次激活您的帐户!'
}
};

View File

@@ -1606,6 +1606,13 @@ body {
}
}
.span-idle {
color: @alert-danger-text !important;
h4 {
color: @alert-danger-text !important;
}
}
.maker-list {
&:not(:first-child) {
&::before {

View File

@@ -29,7 +29,19 @@
}
}, function (err) {
mtDebug.info(err);
NotifycationService.showErrorNotify(err.data.message, 'TORRENT_DOWNLOAD_ERROR');
switch (err.status) {
case 701:
NotifycationService.showErrorNotify('SERVER.ONLY_VIP_CAN_DOWNLOAD', 'TORRENT_DOWNLOAD_ERROR');
break;
case 702:
NotifycationService.showErrorNotify('SERVER.CAN_NOT_DOWNLOAD_BANNED', 'TORRENT_DOWNLOAD_ERROR');
break;
case 703:
NotifycationService.showErrorNotify('SERVER.CAN_NOT_DOWNLOAD_IDLE', 'TORRENT_DOWNLOAD_ERROR');
break;
default:
NotifycationService.showErrorNotify(err.data.message, 'TORRENT_DOWNLOAD_ERROR');
}
});
}

View File

@@ -119,7 +119,12 @@
vm.authentication.user = response;
$rootScope.$broadcast('auth-user-changed');
$rootScope.$broadcast('user-invitations-changed');
NotifycationService.showNotify('info', null, 'Welcome ' + response.displayName);
if (vm.authentication.user.status === 'normal') {
NotifycationService.showNotify('info', null, $translate.instant('SIGN.SIGNIN_WELCOME_NORMAL', {name: response.displayName}));
}
if (vm.authentication.user.status === 'idle') {
NotifycationService.showNotify('error', null, $translate.instant('SIGN.SIGNIN_WELCOME_IDLE', {name: response.displayName}));
}
// And redirect to the previous or home page
$state.go($state.previous.state.name || 'home', $state.previous.params);
}

View File

@@ -58,6 +58,16 @@
<span ng-if="vm.user.makers.length==0">-</span>
</dd>
<dt class="h-line">{{ 'STATUS_FIELD.STATUS' | translate}}</dt>
<dd class="h-line">
<span ng-class="{'span-banned': vm.user.status != 'normal'}">{{ 'STATUS_FIELD.' + vm.user.status.toUpperCase() | translate }}</span>
<div class="pull-right"
ng-if="vm.user.status == 'idle'">
<a ui-sref="active">{{ 'STATUS_FIELD.ACTIVE' | translate }}</a>
</div>
</dd>
<dt class="h-line">{{ 'STATUS_FIELD.SCORE' | translate}}</dt>
<dd class="h-line">
<span class="text-score">{{ vm.user.score | number: 2 }}</span> <span score-level-curr="vm.user"></span> <a

View File

@@ -3,10 +3,15 @@
/**
* Module dependencies
*/
var passport = require('passport'),
var path = require('path'),
config = require(path.resolve('./config/config')),
moment = require('moment'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
User = require('mongoose').model('User');
var signConfig = config.meanTorrentConfig.sign;
module.exports = function () {
// Use local strategy
passport.use(new LocalStrategy(
@@ -43,13 +48,21 @@ module.exports = function () {
message: 'SERVER.YOU_ARE_BANNED'
});
}
if (user.status === 'inactive') {
return done(null, false, {
message: 'SERVER.ACCOUNT_IS_NOT_ACTIVATED'
});
}
if ((moment(Date.now()) - moment(user.last_signed)) > signConfig.accountIdleForTime) {
user.update({
$set: {status: 'idle'}
}).exec();
user.status = 'idle';
}
user.updateSignedTime();
return done(null, user);
});
}