mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-24 07:16:19 +00:00
Redirect to login and remove duplicated code
This commit is contained in:
parent
8f2d964062
commit
76f0292862
|
@ -141,7 +141,7 @@ server.get("/*", async (req, res) => {
|
|||
}
|
||||
|
||||
if (!auth && isAuthPath(path)) {
|
||||
res.redirect("/");
|
||||
res.redirect("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { UserService } from "../../services";
|
|||
|
||||
function AuthGuard(props: { children?: InfernoNode }) {
|
||||
if (!UserService.Instance.myUserInfo) {
|
||||
return <Redirect to="/" />;
|
||||
return <Redirect to="/login" />;
|
||||
} else {
|
||||
return <>{props.children}</>;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
import { Component } from "inferno";
|
||||
import { Redirect } from "inferno-router";
|
||||
import { CommunityView, GetSiteResponse } from "lemmy-js-client";
|
||||
import { Subscription } from "rxjs";
|
||||
import { i18n } from "../../i18next";
|
||||
import { UserService } from "../../services/UserService";
|
||||
import {
|
||||
enableNsfw,
|
||||
isBrowser,
|
||||
|
@ -50,7 +48,6 @@ export class CreateCommunity extends Component<any, CreateCommunityState> {
|
|||
render() {
|
||||
return (
|
||||
<div className="container-lg">
|
||||
{!UserService.Instance.myUserInfo && <Redirect to="/login" />}
|
||||
<HtmlTags
|
||||
title={this.documentTitle}
|
||||
path={this.context.router.route.match.url}
|
||||
|
|
|
@ -111,11 +111,6 @@ export class Inbox extends Component<any, InboxState> {
|
|||
this.handleSortChange = this.handleSortChange.bind(this);
|
||||
this.handlePageChange = this.handlePageChange.bind(this);
|
||||
|
||||
if (!UserService.Instance.myUserInfo && isBrowser()) {
|
||||
toast(i18n.t("not_logged_in"), "danger");
|
||||
this.context.router.history.push(`/login`);
|
||||
}
|
||||
|
||||
this.parseMessage = this.parseMessage.bind(this);
|
||||
this.subscription = wsSubscribe(this.parseMessage);
|
||||
|
||||
|
|
|
@ -59,11 +59,6 @@ export class RegistrationApplications extends Component<
|
|||
|
||||
this.handlePageChange = this.handlePageChange.bind(this);
|
||||
|
||||
if (!UserService.Instance.myUserInfo && isBrowser()) {
|
||||
toast(i18n.t("not_logged_in"), "danger");
|
||||
this.context.router.history.push(`/login`);
|
||||
}
|
||||
|
||||
this.parseMessage = this.parseMessage.bind(this);
|
||||
this.subscription = wsSubscribe(this.parseMessage);
|
||||
|
||||
|
|
|
@ -96,11 +96,6 @@ export class Reports extends Component<any, ReportsState> {
|
|||
|
||||
this.handlePageChange = this.handlePageChange.bind(this);
|
||||
|
||||
if (!UserService.Instance.myUserInfo && isBrowser()) {
|
||||
toast(i18n.t("not_logged_in"), "danger");
|
||||
this.context.router.history.push(`/login`);
|
||||
}
|
||||
|
||||
this.parseMessage = this.parseMessage.bind(this);
|
||||
this.subscription = wsSubscribe(this.parseMessage);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Component } from "inferno";
|
||||
import { Redirect } from "inferno-router";
|
||||
import { RouteComponentProps } from "inferno-router/dist/Route";
|
||||
import {
|
||||
GetCommunity,
|
||||
|
@ -13,7 +12,7 @@ import {
|
|||
import { Subscription } from "rxjs";
|
||||
import { InitialFetchRequest, PostFormParams } from "shared/interfaces";
|
||||
import { i18n } from "../../i18next";
|
||||
import { UserService, WebSocketService } from "../../services";
|
||||
import { WebSocketService } from "../../services";
|
||||
import {
|
||||
Choice,
|
||||
QueryParams,
|
||||
|
@ -145,7 +144,6 @@ export class CreatePost extends Component<
|
|||
|
||||
return (
|
||||
<div className="container-lg">
|
||||
{!UserService.Instance.myUserInfo && <Redirect to="/login" />}
|
||||
<HtmlTags
|
||||
title={this.documentTitle}
|
||||
path={this.context.router.route.match.url}
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
import { Subscription } from "rxjs";
|
||||
import { i18n } from "../../i18next";
|
||||
import { InitialFetchRequest } from "../../interfaces";
|
||||
import { UserService, WebSocketService } from "../../services";
|
||||
import { WebSocketService } from "../../services";
|
||||
import {
|
||||
getRecipientIdFromProps,
|
||||
isBrowser,
|
||||
|
@ -51,11 +51,6 @@ export class CreatePrivateMessage extends Component<
|
|||
this.parseMessage = this.parseMessage.bind(this);
|
||||
this.subscription = wsSubscribe(this.parseMessage);
|
||||
|
||||
if (!UserService.Instance.myUserInfo && isBrowser()) {
|
||||
toast(i18n.t("not_logged_in"), "danger");
|
||||
this.context.router.history.push(`/login`);
|
||||
}
|
||||
|
||||
// Only fetch the data if coming from another route
|
||||
if (this.isoData.path == this.context.router.route.match.url) {
|
||||
this.state = {
|
||||
|
|
Loading…
Reference in a new issue