Skip to content

Commit e6e706a

Browse files
committed
Fix for not redirecting to invitation
1 parent c975259 commit e6e706a

11 files changed

Lines changed: 42 additions & 27 deletions

File tree

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>invite</artifactId>
7-
<version>0.0.31</version>
7+
<version>0.0.32-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-client</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.openconext</groupId>
55
<artifactId>invite</artifactId>
6-
<version>0.0.31</version>
6+
<version>0.0.32-SNAPSHOT</version>
77
<packaging>pom</packaging>
88
<name>invite</name>
99
<description>SURFconext Invite</description>

provisioning-mock/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>invite</artifactId>
7-
<version>0.0.31</version>
7+
<version>0.0.32-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>provisioning-mock</artifactId>

server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>invite</artifactId>
7-
<version>0.0.31</version>
7+
<version>0.0.32-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-server</artifactId>

server/src/main/java/access/api/UserController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.data.domain.Sort;
3232
import org.springframework.http.MediaType;
3333
import org.springframework.http.ResponseEntity;
34+
import org.springframework.security.core.Authentication;
3435
import org.springframework.security.core.context.SecurityContextHolder;
3536
import org.springframework.transaction.annotation.Transactional;
3637
import org.springframework.util.StringUtils;
@@ -95,6 +96,7 @@ public UserController(Config config,
9596
public ResponseEntity<Config> config(User user,
9697
@RequestParam(value = "guest", required = false, defaultValue = "false") boolean guest) {
9798
LOG.debug("GET /config");
99+
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
98100
Config result = new Config(this.config);
99101
result
100102
.withAuthenticated(user != null && user.getId() != null)

server/src/main/resources/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ email:
195195
# configure real users / passwords and test against those. See server/src/main/java/access/manage/ManageConf.java
196196
# and server/src/main/java/access/manage/LocalManage.java to see how it works.
197197
manage:
198-
# enabled: True
199-
enabled: False
198+
enabled: True
199+
# enabled: False
200200
url: "https://manage.test2.surfconext.nl"
201201
user: invite
202202
password: secret

welcome/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"react": "^19.1.0",
1313
"react-copy-to-clipboard": "^5.1.0",
1414
"react-dom": "^19.1.0",
15-
"react-router": "^7.5.3",
16-
"react-router-dom": "^7.5.3",
15+
"react-router": "7.3.0",
16+
"react-router-dom": "7.3.0",
1717
"react-tooltip": "^5.28.1",
1818
"timeago.js": "^4.0.2",
1919
"word-wrap": "^1.2.5",

welcome/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.openconext</groupId>
66
<artifactId>invite</artifactId>
7-
<version>0.0.31</version>
7+
<version>0.0.32-SNAPSHOT</version>
88
<relativePath>../pom.xml</relativePath>
99
</parent>
1010
<artifactId>access-welcome</artifactId>

welcome/src/pages/App.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,36 +30,40 @@ export const App = () => {
3030
configuration()
3131
.then(res => {
3232
useAppStore.setState(() => ({config: res}));
33+
3334
if (!res.authenticated) {
3435
if (!res.name) {
3536
const direction = window.location.pathname + window.location.search;
3637
localStorage.setItem("location", direction);
3738
} else if (!isEmpty(res.missingAttributes)) {
38-
setLoading(false);
3939
navigate("/missingAttributes");
40+
setLoading(false);
4041
return;
4142
}
42-
setLoading(false);
4343
const locationStored = localStorage.getItem("location");
4444
const pathname = locationStored || window.location.pathname;
45-
const isInvitationAcceptFlow = window.location.pathname.startsWith("/invitation/accept");
45+
const isInvitationAcceptFlow = window.location.pathname.startsWith("/invitation/accept")
46+
|| pathname.startsWith("/invitation/accept");
4647
if (res.name && !pathname.startsWith("/invitation/accept") && !isInvitationAcceptFlow) {
4748
navigate("/deadend");
48-
} else if (pathname === "/" || pathname.startsWith("/login") || pathname.startsWith("/invitation/accept") || isInvitationAcceptFlow) {
49-
navigate(isInvitationAcceptFlow ? (window.location.pathname + window.location.search) : pathname);
49+
} else if (pathname === "/" || pathname.startsWith("/login") || isInvitationAcceptFlow) {
50+
const route = isInvitationAcceptFlow ? pathname : (window.location.pathname + window.location.search);
51+
setTimeout(() => navigate(route), 15);
52+
navigate(route);
5053
} else {
5154
//Bookmarked URL's trigger a direct login and skip the landing page
5255
login(res);
5356
}
57+
setLoading(false);
5458
} else {
5559
me()
5660
.then(res => {
5761
useAppStore.setState(() => ({user: res, authenticated: true}));
5862
const location = localStorage.getItem("location") || window.location.pathname + window.location.search;
5963
const newLocation = location.startsWith("/login") ? "/profile" : location;
6064
localStorage.removeItem("location");
61-
setLoading(false);
6265
navigate(newLocation);
66+
setLoading(false);
6367
});
6468
}
6569
})
@@ -73,6 +77,7 @@ export const App = () => {
7377
if (loading) {
7478
return <Loader/>
7579
}
80+
7681
return (
7782
<div className="access">
7883
<div className="container">
@@ -92,8 +97,7 @@ export const App = () => {
9297
<Routes>
9398
<Route path="/" element={<Navigate replace to="login"/>}/>
9499
<Route path="proceed" element={<Proceed/>}/>
95-
<Route path="invitation/accept"
96-
element={<Invitation authenticated={false}/>}/>
100+
<Route path="invitation/accept" element={<Invitation authenticated={false}/>}/>
97101
<Route path="login" element={<Login/>}/>
98102
<Route path="deadend" element={<InviteOnly/>}/>
99103
<Route path="missingAttributes" element={<MissingAttributes/>}/>

welcome/src/pages/Invitation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const HAS_LOGGED_IN_AGAIN = "hasLoggedInAgain"
2222
let runOnce = false;
2323

2424
export const Invitation = ({authenticated}) => {
25-
25+
2626
const navigate = useNavigate();
2727
const {user, config} = useAppStore(state => state);
2828

@@ -34,12 +34,14 @@ export const Invitation = ({authenticated}) => {
3434

3535
useEffect(() => {
3636
const hashParam = getParameterByName("hash", window.location.search);
37+
3738
if (runOnce) {
3839
return;
3940
}
4041
runOnce = true;
4142
invitationByHash(hashParam)
4243
.then(res => {
44+
4345
setInvitation(res);
4446
useAppStore.setState(() => ({
4547
invitation: res
@@ -65,6 +67,7 @@ export const Invitation = ({authenticated}) => {
6567
})
6668
})
6769
.catch(e => {
70+
6871
setLoading(false);
6972
if (e.response && e.response.status === 412) {
7073
setConfirmation({

0 commit comments

Comments
 (0)