Skip to content

Commit e6f0cfe

Browse files
committed
chore: remove unused auth endpoints and function
The getUser function on git-push.js (which used the api/auth/success endpoint) was exported but not used anywhere else
1 parent 9a0276e commit e6f0cfe

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
lines changed

src/service/routes/auth.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,6 @@ router.get('/oidc/callback', (req, res, next) => {
6565
})(req, res, next);
6666
});
6767

68-
// when login is successful, retrieve user info
69-
router.get('/success', (req, res) => {
70-
console.log('authenticated' + JSON.stringify(req.user));
71-
if (req.user) {
72-
res.json({
73-
success: true,
74-
message: 'user has successfully authenticated',
75-
user: req.user,
76-
cookies: req.cookies,
77-
});
78-
} else {
79-
res.status(401).end();
80-
}
81-
});
82-
83-
// when login failed, send failed msg
84-
router.get('failed', (req, res) => {
85-
res.status(401).json({
86-
success: false,
87-
message: 'user failed to authenticate.',
88-
});
89-
});
90-
9168
router.post('/logout', (req, res, next) => {
9269
req.logout(req.user, (err) => {
9370
if (err) return next(err);

src/ui/services/git-push.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,6 @@ const config = {
99
withCredentials: true,
1010
};
1111

12-
const getUser = async (setIsLoading, setData, setAuth, setIsError) => {
13-
const url = new URL(`${location.origin}/api/auth/success`);
14-
await axios(url.toString(), config)
15-
.then((response) => {
16-
const data = response.data;
17-
setData(data);
18-
setIsLoading(false);
19-
})
20-
.catch((error) => {
21-
if (error.response && error.response.status === 401) setAuth(false);
22-
else setIsError(true);
23-
setIsLoading(false);
24-
});
25-
};
26-
2712
const getPush = async (id, setIsLoading, setData, setAuth, setIsError) => {
2813
const url = `${baseUrl}/push/${id}`;
2914
await axios(url, config)

test/testLogin.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ describe('auth', async () => {
112112
const res = await chai.request(app).get('/api/auth/me');
113113
res.should.have.status(401);
114114
});
115+
116+
it('should fail to login with invalid credentials', async function () {
117+
const res = await chai.request(app).post('/api/auth/login').send({
118+
username: 'admin',
119+
password: 'invalid',
120+
});
121+
res.should.have.status(401);
122+
});
115123
});
116124

117125
after(async function () {

0 commit comments

Comments
 (0)