Skip to content

Commit

Permalink
refactor!: drop codePushWeb redirect support
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwind committed Feb 9, 2022
1 parent 98c2ca6 commit 255ea15
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 47 deletions.
3 changes: 0 additions & 3 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ export const config = {
updateCheckCache: toBool(process.env.UPDATE_CHECK_CACHE),
// options value is (true | false), when it's true, it will cache rollout results in redis
rolloutClientUniqueIdCache: toBool(process.env.ROLLOUT_CLIENT_UNIQUE_ID_CACHE),

// CodePush Web(https://github.com/lisong/code-push-web) login address.
//codePushWebUrl: "http://127.0.0.1:3001/login",
},
// Config for smtp email,register module need validate user email project source https://github.com/nodemailer/nodemailer
smtpConfig: {
Expand Down
21 changes: 4 additions & 17 deletions src/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,18 @@ router.get('/password', (req, res) => {
});

router.get('/login', (req, res) => {
var codePushWebUrl = _.get(config, 'common.codePushWebUrl');
if (codePushWebUrl && validator.isURL(codePushWebUrl)) {
logger.debug(`login redirect:${codePushWebUrl}`);
res.redirect(`${codePushWebUrl}/login`);
} else {
res.render('auth/login', { title: 'CodePushServer', email: req.query.email || '' });
}
res.render('auth/login', { title: 'CodePushServer', email: req.query.email || '' });
});

router.get('/link', (req, res) => {
res.redirect(`/auth/login`);
});

router.get('/register', (req, res) => {
var codePushWebUrl = _.get(config, 'common.codePushWebUrl');
var isRedirect = false;
if (codePushWebUrl && validator.isURL(codePushWebUrl)) {
logger.debug(`register redirect:${codePushWebUrl}`);
res.redirect(`${codePushWebUrl}/register`);
if (_.get(config, 'common.allowRegistration')) {
res.render('auth/register', { title: 'CodePushServer', email: req.query.email || '' });
} else {
if (_.get(config, 'common.allowRegistration')) {
res.render('auth/register', { title: 'CodePushServer', email: req.query.email || '' });
} else {
res.redirect(`/auth/login`);
}
res.redirect(`/auth/login`);
}
});

Expand Down
27 changes: 0 additions & 27 deletions tests/api/auth/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@ describe('api/auth/test.js', function () {
var password = '123456';

describe('sign in view', function (done) {
it('should show sign in redirect view successful', function (done) {
_.set(config, 'common.codePushWebUrl', 'http://127.0.0.1:3001');
request
.get('/auth/login')
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(302);
done();
});
});

it('should show sign in view successful', function (done) {
_.set(config, 'common.codePushWebUrl', null);
request
.get('/auth/login')
.send()
Expand All @@ -48,21 +35,7 @@ describe('api/auth/test.js', function () {
});
});

it('should show sign up redirect view successful', function (done) {
_.set(config, 'common.codePushWebUrl', 'http://127.0.0.1:3001');
_.set(config, 'common.allowRegistration', true);
request
.get('/auth/register')
.send()
.end(function (err, res) {
should.not.exist(err);
res.status.should.equal(302);
done();
});
});

it('should show sign up view successful', function (done) {
_.set(config, 'common.codePushWebUrl', null);
_.set(config, 'common.allowRegistration', true);
request
.get('/auth/register')
Expand Down

0 comments on commit 255ea15

Please sign in to comment.