Redirected Home page to Bookmarks list page when authenticated and lo… #26
@ -113,14 +113,10 @@ namespace YABA.Service
|
|||||||
bookmark.Url = !string.IsNullOrEmpty(request.Url) ? request.Url : bookmark.Url;
|
bookmark.Url = !string.IsNullOrEmpty(request.Url) ? request.Url : bookmark.Url;
|
||||||
UpdateBookmarkWithMetaData(bookmark);
|
UpdateBookmarkWithMetaData(bookmark);
|
||||||
|
|
||||||
if (await _context.SaveChangesAsync() > 0)
|
await _context.SaveChangesAsync();
|
||||||
{
|
var bookmarkDTO = _mapper.Map<BookmarkDTO>(bookmark);
|
||||||
var bookmarkDTO = _mapper.Map<BookmarkDTO>(bookmark);
|
bookmarkDTO.Tags = tags;
|
||||||
bookmarkDTO.Tags = tags;
|
return bookmarkDTO;
|
||||||
return bookmarkDTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TagDTO>?> UpdateBookmarkTags(int id, IEnumerable<string> tags)
|
public async Task<IEnumerable<TagDTO>?> UpdateBookmarkTags(int id, IEnumerable<string> tags)
|
||||||
|
|||||||
@ -11,7 +11,7 @@ export function Header(props) {
|
|||||||
const handleLogin = async () => {
|
const handleLogin = async () => {
|
||||||
await loginWithRedirect({
|
await loginWithRedirect({
|
||||||
appState: {
|
appState: {
|
||||||
returnTo: "/",
|
returnTo: "/bookmarks",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -19,7 +19,7 @@ export function Header(props) {
|
|||||||
const handleSignUp = async () => {
|
const handleSignUp = async () => {
|
||||||
await loginWithRedirect({
|
await loginWithRedirect({
|
||||||
appState: {
|
appState: {
|
||||||
returnTo: "/",
|
returnTo: "/bookmarks",
|
||||||
},
|
},
|
||||||
authorizationParams: {
|
authorizationParams: {
|
||||||
screen_hint: "signup",
|
screen_hint: "signup",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useReducer, useState } from "react";
|
import React, { useEffect, useReducer, useState } from "react";
|
||||||
import { Alert, Col, Container, Row, Button, Modal, Dropdown, DropdownButton } from "../components/external";
|
import { Alert, Col, Container, Row, Button, Modal } from "../components/external";
|
||||||
import { Bookmark } from "../components";
|
import { Bookmark } from "../components";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
import { deleteBookmarks, getAllBookmarks, hideBookmarks } from "../api";
|
import { deleteBookmarks, getAllBookmarks, hideBookmarks } from "../api";
|
||||||
|
|||||||
@ -1,20 +1,31 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import Container from 'react-bootstrap/Container';
|
import Container from 'react-bootstrap/Container';
|
||||||
import Row from 'react-bootstrap/Row';
|
import Row from 'react-bootstrap/Row';
|
||||||
import Col from 'react-bootstrap/Col';
|
import Col from 'react-bootstrap/Col';
|
||||||
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
export function HomeView(props) {
|
export function HomeView(props) {
|
||||||
|
const { isAuthenticated, loginWithRedirect } = useAuth0();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const navigateToLogin = async () => {
|
||||||
|
await loginWithRedirect({
|
||||||
|
appState: {
|
||||||
|
returnTo: "/bookmarks",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if(isAuthenticated) {
|
||||||
|
navigate("/bookmarks");
|
||||||
|
} else {
|
||||||
|
navigateToLogin();
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<React.Fragment>
|
<></>
|
||||||
<div style={{flexGrow: 1}}>
|
|
||||||
<Container>
|
|
||||||
<Row>
|
|
||||||
<Col xs="9">
|
|
||||||
<h1>This is the Home View</h1>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Container>
|
|
||||||
</div>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user