mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-04 12:58:48 +02:00
fix(core): fixed limited ip for admin center issue
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
.module('core')
|
||||
.run(routeFilter);
|
||||
|
||||
routeFilter.$inject = ['$rootScope', '$state', 'Authentication', 'MeanTorrentConfig'];
|
||||
routeFilter.$inject = ['$rootScope', '$state', 'Authentication', 'MeanTorrentConfig', 'UsersService'];
|
||||
|
||||
function routeFilter($rootScope, $state, Authentication, MeanTorrentConfig) {
|
||||
function routeFilter($rootScope, $state, Authentication, MeanTorrentConfig, UsersService) {
|
||||
$rootScope.$on('$stateChangeStart', stateChangeStart);
|
||||
$rootScope.$on('$stateChangeSuccess', stateChangeSuccess);
|
||||
|
||||
@@ -41,11 +41,14 @@
|
||||
} else {
|
||||
if (toState.name.startsWith('admin.')) {
|
||||
var adminAccessConfig = MeanTorrentConfig.meanTorrentConfig.adminAccess;
|
||||
|
||||
if (adminAccessConfig.limit) {
|
||||
if (Authentication.user && !adminAccessConfig.limitedIp.includes(Authentication.user.curr_signed_ip)) {
|
||||
event.preventDefault();
|
||||
$state.transitionTo('access-deny');
|
||||
}
|
||||
UsersService.getMyIp(function (res) {
|
||||
if (Authentication.user && !adminAccessConfig.limitedIp.includes(res.ip)) {
|
||||
event.preventDefault();
|
||||
$state.transitionTo('access-deny');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,10 @@
|
||||
method: 'GET',
|
||||
url: '/api/users/:userId/following',
|
||||
isArray: true
|
||||
},
|
||||
getMyIp: {
|
||||
method: 'GET',
|
||||
url: '/api/users/myIp'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -288,3 +288,14 @@ exports.unIdle = function (req, res, next) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* getMyIp
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.getMyIp = function (req, res) {
|
||||
res.status(200).send({
|
||||
ip: req.user.curr_signed_ip
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ module.exports = function (app) {
|
||||
|
||||
// Setting up the users profile api
|
||||
app.route('/api/users/me').get(users.me);
|
||||
app.route('/api/users/myIp').get(users.getMyIp);
|
||||
app.route('/api/users').put(users.update);
|
||||
app.route('/api/users/accounts').delete(users.removeOAuthProvider);
|
||||
app.route('/api/users/password').post(users.changePassword);
|
||||
|
||||
Reference in New Issue
Block a user