Skip to content

Commit

Permalink
Merge pull request #55 from elixir-europe/elixir-bsc
Browse files Browse the repository at this point in the history
userName saved when refreshing
  • Loading branch information
Gemma Milla authored Feb 14, 2024
2 parents 3bf4225 + 4ca4664 commit 2a54ca3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions frontend/src/components/Datasets/ResultsDatasets.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ p a {
.resultsRecord {
display: flex;
flex-direction: row;
height: 140%;
flex-wrap: wrap;
justify-content: center;
align-content: center;
padding-bottom: 10px;
padding-bottom: 60px;
margin-top: 60px;
}

@media (max-width: 860px) {
Expand Down Expand Up @@ -258,8 +258,8 @@ p a {
justify-content: center;
align-content: center;
width: 100vw;
padding-bottom: 10px;
height: 160%;
margin-top: 60px;
padding-bottom: 60px;
}

.tittle4 {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NavBar/Navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@

.Members3:hover ~ .animation {
width: 150px;
right: 349px;
right: 20.5%;
background-color: #4961b8;
}

Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/NavBar/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ function Navbar () {
logOutUser,
authenticateUser,
getStoredToken,
userNameToShare
userNameToShare,
setUserNameToShare
} = useContext(AuthContext)

const auth = useAuth()
const navigate = useNavigate()

useEffect(() => {
let user = localStorage.getItem('userName')
if (user !== ''){
setUserNameToShare(user)
}
authenticateUser()
let token = getStoredToken()
let isAuthenticated = false
Expand All @@ -39,7 +44,7 @@ function Navbar () {
} else {
setIsLoggedIn(false)
}
}, [])
}, [userNameToShare])

const handleHelpModal1 = () => {
setIsOpenModal1(true)
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/SignIn/LoggedIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const LoggedIn = () => {

if (auth && auth.userData) {
setIsLoggedIn(true)
setUserNameToShare(auth.userData.profile.name)

setUserNameToShare(
localStorage.setItem('userName', auth.userData.profile.name)
)

return (
<div>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/SignIn/SignInFormNoLS.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default function SignInFormNoLS () {
const [error, setError] = useState('')

const navigate = useNavigate()

const {
storeToken,
setIsLoggedIn,
Expand Down Expand Up @@ -77,7 +78,7 @@ export default function SignInFormNoLS () {
if (readableResponse.access_token) {
navigate('/')
setIsLoggedIn(true)
setUserNameToShare(userName)
setUserNameToShare(localStorage.setItem('userName', userName))
} else {
setError(
'User not found. Please check the username and the password and retry'
Expand Down

0 comments on commit 2a54ca3

Please sign in to comment.