Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ DECLARE
l_roles OWA.VC_ARR;
l_modules OWA.VC_ARR;
l_patterns OWA.VC_ARR;

BEGIN
ORDS.ENABLE_SCHEMA(
p_enabled => TRUE,
Expand Down Expand Up @@ -399,18 +399,8 @@ BEGIN
p_source =>
'SELECT * FROM MUSIC_GENRES');



l_modules(1) := 'concert_app.euser.v1';

ORDS.DEFINE_PRIVILEGE(
p_privilege_name => 'concert_app_euser',
p_roles => l_roles,
p_patterns => l_patterns,
p_modules => l_modules,
p_label => 'Non authenticated end user privilege',
p_description => 'Provides limited access to the concert app endpoints',
p_comments => NULL);

l_roles.DELETE;
l_modules.DELETE;
Expand Down
5 changes: 2 additions & 3 deletions templates/ords-remix-jwt-sample/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
} from './utils/auth.server';
import NavBar from './components/navbar/NavBar';
import {
BASIC_SCHEMA_AUTH,
CITIES_ENDPOINT,
} from './routes/constants/index.server';
import TooltipButton from './components/tooltips/TooltipButton';
Expand All @@ -42,12 +41,12 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
const userProfile = await auth.isAuthenticated(request);
const profile = userProfile?.profile || null;
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;

const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
if (cities.items.length === 0) {
const errorMessage = 'The cities endpoint has no elements. Review your database configuration and try again.';
throw new Response(errorMessage, {
Expand Down
13 changes: 6 additions & 7 deletions templates/ords-remix-jwt-sample/app/routes/artists.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
ARTISTS_ENDPOINT,
ARTIST_ENDPOINT,
ARTIST_EVENT_ENDPOINT,
BASIC_SCHEMA_AUTH,
CITIES_ENDPOINT,
LIKED_ARTIST_ENDPOINT,
} from './constants/index.server';
Expand Down Expand Up @@ -87,26 +86,26 @@ export const loader = async ({
const userProfile = await auth.isAuthenticated(request);
const profile = userProfile?.profile || null;
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const { id: artistID } = params;
let likedArtist = false;
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS) as ORDSResponse<Artist>;
const artist = await ORDSFetcher(`${ARTIST_ENDPOINT}/${artistID}`, USER_CREDENTIALS!) as ORDSResponse<Artist>;
if (artist.items.length === 0) {
const errorMessage = 'The Artist you were looking for does not exist, might have been removed or had its id changed.';
throw new Response(errorMessage, {
status: 404,
statusText: 'Not Found',
} as ErrorResponse);
}
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS);
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS);
const artistEvents = await ORDSFetcher(`${ARTIST_EVENT_ENDPOINT}/${artistID}`, USER_CREDENTIALS!);
const similarArtists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!);
if (profile) {
const userID = profile.id;
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS);
const userLikedArtist = await ORDSFetcher(`${LIKED_ARTIST_ENDPOINT}/${userID}/${artistID}`, USER_CREDENTIALS!);
likedArtist = userLikedArtist.likedartist === 1;
}
return json({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import ConcertDetails from '../components/concerts/ConcertDetails';
import {
EVENT_ENDPOINT,
LIKED_EVENT_ENDPOINT,
BASIC_SCHEMA_AUTH,
} from './constants/index.server';
import { UserActions } from '../utils/UserActions';
import ORDSFetcher from '../utils/ORDSFetcher';
Expand Down Expand Up @@ -93,12 +92,12 @@ export const loader = async ({
const userProfile = await auth.isAuthenticated(request);
const profile = userProfile?.profile || null;
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const { concertID } = params;
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS) as ORDSResponse<Concert>;
const concert = await ORDSFetcher(`${EVENT_ENDPOINT}/${concertID}`, USER_CREDENTIALS!) as ORDSResponse<Concert>;
if (concert.items.length === 0) {
const errorMessage = 'The Concert you were looking for does not exist, might have been removed or had its id changed.';
throw new Response(errorMessage, {
Expand All @@ -109,7 +108,7 @@ export const loader = async ({
let likedConcert = false;
if (profile !== null) {
const userID = profile.id;
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS);
const userLikedConcert = await ORDSFetcher(`${LIKED_EVENT_ENDPOINT}/${userID}/${concertID}`, USER_CREDENTIALS!);
likedConcert = userLikedConcert.likedevent === 1;
}

Expand Down
9 changes: 4 additions & 5 deletions templates/ords-remix-jwt-sample/app/routes/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from '../utils/auth.server';
import {
STATS_ENDPOINT,
BASIC_SCHEMA_AUTH,
EVENTS_ENDPOINT,
ARTISTS_ENDPOINT,
CONCERTS_BY_CITY_ENDPOINT,
Expand All @@ -43,17 +42,17 @@ import featureDescriptions from '../utils/ORDSFeaturesDescription';
export const loader = async ({ request }: LoaderFunctionArgs) => {
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const { searchParams } = new URL(request.url);
const hasCityName = searchParams.has('cityName');
const cityName = searchParams.get('cityName');
const eventsQuery = hasCityName ? `${CONCERTS_BY_CITY_ENDPOINT}/${cityName}` : EVENTS_ENDPOINT;
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS);
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS);
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS);
const stats = await ORDSFetcher(STATS_ENDPOINT, USER_CREDENTIALS!);
const events = await ORDSFetcher(eventsQuery, USER_CREDENTIALS!);
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!);
return json({
error,
stats,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '~/utils/auth.server';
import {
ARTISTS_ENDPOINT,
BASIC_SCHEMA_AUTH,
} from './constants/index.server';
import ORDSFetcher from '../utils/ORDSFetcher';

Expand All @@ -29,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
artistsURL.searchParams.append('limit', limit.toString());
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS);
const artists = await ORDSFetcher(artistsURL, USER_CREDENTIALS!);
return json({
error,
artists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '~/utils/auth.server';
import {
CITIES_ENDPOINT,
BASIC_SCHEMA_AUTH,
} from './constants/index.server';
import ORDSFetcher from '../utils/ORDSFetcher';

Expand All @@ -29,11 +28,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
citiesURL.searchParams.append('limit', limit.toString());
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS);
const cities = await ORDSFetcher(citiesURL, USER_CREDENTIALS!);
return json({
error,
cities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '~/utils/auth.server';
import {
EVENTS_ENDPOINT,
BASIC_SCHEMA_AUTH,
CONCERTS_BY_CITY_ENDPOINT,
} from './constants/index.server';
import ORDSFetcher from '../utils/ORDSFetcher';
Expand All @@ -33,11 +32,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
eventsURL.searchParams.append('limit', limit.toString());
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS);
const events = await ORDSFetcher(eventsURL, USER_CREDENTIALS!);
return json({
error,
events,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
getSession,
} from '~/utils/auth.server';
import {
BASIC_SCHEMA_AUTH,
MUSIC_GENRES_ENDPOINT,
} from './constants/index.server';
import ORDSFetcher from '../utils/ORDSFetcher';
Expand All @@ -31,13 +30,13 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
musicGenresURL.searchParams.append('limit', limit.toString());
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const musicGenres = await ORDSFetcher(
musicGenresURL,
USER_CREDENTIALS,
USER_CREDENTIALS!,
) as ORDSResponse<MusicGenre>;
return json({
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '~/utils/auth.server';
import {
VENUES_ENDPOINT,
BASIC_SCHEMA_AUTH,
} from './constants/index.server';
import ORDSFetcher from '../utils/ORDSFetcher';
import ORDSResponse from '../models/ORDSResponse';
Expand All @@ -31,11 +30,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
venuesURL.searchParams.append('limit', limit.toString());
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
const venues = await ORDSFetcher(venuesURL, USER_CREDENTIALS) as ORDSResponse<Venue>;
const venues = await ORDSFetcher(venuesURL, USER_CREDENTIALS!) as ORDSResponse<Venue>;
return json({
error,
venues,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type {
import { json } from '@remix-run/node';
import { auth } from '~/utils/auth.server';
import {
BASIC_SCHEMA_AUTH,
ARTISTS_ENDPOINT,
VENUES_ENDPOINT,
EVENTS_BY_NAME_ENDPOINT,
Expand All @@ -30,14 +29,14 @@ export const loader = async ({
const { searchKind, searchParam } = params;
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
// eslint-disable-next-line no-magic-numbers
const FOLLOWERS = [69420, 99876, 45632, 32496, 98765, 12776, 100000, 88999, 99999];

switch (searchKind) {
case 'Artists': {
const artists = await ORDSFetcher(`${ARTISTS_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
const artists = await ORDSFetcher(`${ARTISTS_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
const SearchResult = artists.items.map((artist: Artist, index : number) => ({
id: artist.artist_id,
kind: 'artists',
Expand All @@ -50,7 +49,7 @@ export const loader = async ({
});
}
case 'Events': {
const events = await ORDSFetcher(`${EVENTS_BY_NAME_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
const events = await ORDSFetcher(`${EVENTS_BY_NAME_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
const SearchResult = events.items.map((event: Concert) => ({
id: event.event_id,
kind: 'concerts',
Expand All @@ -63,7 +62,7 @@ export const loader = async ({
});
}
case 'Venues': {
const venues = await ORDSFetcher(`${VENUES_ENDPOINT}/${searchParam}`, USER_CREDENTIALS);
const venues = await ORDSFetcher(`${VENUES_ENDPOINT}/${searchParam}`, USER_CREDENTIALS!);
const SearchResult = venues.items.map((venue: Venue) => ({
id: venue.venue_id,
kind: 'venues',
Expand All @@ -79,7 +78,7 @@ export const loader = async ({
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: USER_CREDENTIALS,
Authorization: USER_CREDENTIALS!,
},
});
const artists = await getArtist.json();
Expand Down
7 changes: 3 additions & 4 deletions templates/ords-remix-jwt-sample/app/routes/search.artists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
auth, getSession,
} from '../utils/auth.server';
import {
BASIC_SCHEMA_AUTH,
MUSIC_GENRES_ENDPOINT,
AUTO_REST_SEARCH_ARTISTS_ENDPOINT,
} from './constants/index.server';
Expand All @@ -34,7 +33,7 @@ import DiscoverArtists from '../components/search/DiscoverArtists';
export const loader = async ({ request }: LoaderFunctionArgs) => {
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
Expand All @@ -51,11 +50,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
searchURL.searchParams.append('offset', offset.toString());
const searchResult = await ORDSFetcher(
searchURL,
USER_CREDENTIALS,
USER_CREDENTIALS!,
) as ORDSResponse<ArtistResult>;
const musicGenres = await ORDSFetcher(
MUSIC_GENRES_ENDPOINT,
USER_CREDENTIALS,
USER_CREDENTIALS!,
) as ORDSResponse<MusicGenre>;

return json({
Expand Down
11 changes: 5 additions & 6 deletions templates/ords-remix-jwt-sample/app/routes/search.concerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
auth, getSession,
} from '../utils/auth.server';
import {
BASIC_SCHEMA_AUTH,
AUTO_REST_SEARCH_ENDPOINT,
CITIES_ENDPOINT,
ARTISTS_ENDPOINT,
Expand All @@ -38,7 +37,7 @@ import Artist from '../models/Artist';
export const loader = async ({ request }: LoaderFunctionArgs) => {
const userProfile = await auth.isAuthenticated(request);
const USER_CREDENTIALS = userProfile === null
? BASIC_SCHEMA_AUTH
? null
: `${userProfile.tokenType} ${userProfile.accessToken}`;
const session = await getSession(request.headers.get('Cookie'));
const error = session.get(auth.sessionErrorKey) as LoaderError;
Expand All @@ -55,11 +54,11 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
searchURL.searchParams.append('offset', offset.toString());
const searchResult = await ORDSFetcher(
searchURL,
USER_CREDENTIALS,
USER_CREDENTIALS!,
) as ORDSResponse<SearchResult>;
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS) as ORDSResponse<City>;
const venues = await ORDSFetcher(VENUES_ENDPOINT, USER_CREDENTIALS) as ORDSResponse<Venue>;
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS) as ORDSResponse<Artist>;
const cities = await ORDSFetcher(CITIES_ENDPOINT, USER_CREDENTIALS!) as ORDSResponse<City>;
const venues = await ORDSFetcher(VENUES_ENDPOINT, USER_CREDENTIALS!) as ORDSResponse<Venue>;
const artists = await ORDSFetcher(ARTISTS_ENDPOINT, USER_CREDENTIALS!) as ORDSResponse<Artist>;

return json({
error,
Expand Down
Loading