Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Added security stamp system to invalidate user sessions when oauth allowed roles change

Albert Nimtzea5979b1f362
diff --git a/app/middlewares/user.go b/app/middlewares/user.go
index c29cbea59..320856871 100644
--- a/app/middlewares/user.go
+++ b/app/middlewares/user.go
@@ -2,6 +2,7 @@ package middlewares
import (
"fmt"
+ "net/url"
"strconv"
"strings"
@@ -55,6 +56,26 @@ func User() web.MiddlewareFunc {
}
return err
}
+
+ // Security stamp check: if the JWT contains a stamp (new tokens only),
+ // validate it against the current DB stamp. A mismatch means the user's
+ // security-relevant data has changed (e.g. role changed, account blocked,
+ // or OAuth allowed-roles updated) and they must re-authenticate so that
+ // access controls are re-evaluated.
+ if claims.SecurityStamp != "" && user != nil && claims.SecurityStamp != user.SecurityStamp {
+ c.RemoveCookie(web.CookieAuthName)
+ if c.IsAjax() {
+ return c.JSON(401, web.Map{})
+ }
+ redirectTarget := c.Request.URL.RequestURI()
+ if redirectTarget != "" &&
+ redirectTarget != "/" &&
+ !strings.HasPrefix(redirectTarget, "/signin") &&
+ !strings.HasPrefix(redirectTarget, "/signout") {
+ return c.Redirect("/signin?redirect=" + url.QueryEscape(redirectTarget))
+ }
+ return c.Redirect("/signin")
+ }
} else if c.Request.IsAPI() {
authHeader := c.Request.GetHeader("Authorization")
parts := strings.Split(authHeader, "Bearer")
diff --git a/app/middlewares/user_test.go b/app/middlewares/user_test.go
index b570c1ce5..b1e09495a 100644
--- a/app/middlewares/user_test.go
+++ b/app/middlewares/user_test.go
@@ -426,3 +426,184 @@ func TestUser_Impersonation_ValidUser(t *testing.T) {
Expect(status).Equals(http.StatusOK)
Expect(response.Body.String()).Equals("Arya Stark")
}
+
+// TestUser_SecurityStamp_Match verifies that a token whose security stamp
+// matches the DB value grants access normally.
+func TestUser_SecurityStamp_Match(t *testing.T) {
+ RegisterT(t)
+
+ userWithStamp := &entity.User{
+ ID: mock.JonSnow.ID,
+ Name: mock.JonSnow.Name,
+ Email: mock.JonSnow.Email,
+ Tenant: mock.DemoTenant,
+ Status: enum.UserActive,
+ Role: enum.RoleAdministrator,
+ SecurityStamp: "stamp-abc123",
+ Providers: mock.JonSnow.Providers,
+ }
+
+ token, _ := jwt.Encode(jwt.FiderClaims{
+ UserID: userWithStamp.ID,
+ UserName: userWithStamp.Name,
+ SecurityStamp: "stamp-abc123",
+ })
+
+ bus.AddHandler(func(ctx context.Context, q *query.GetUserByID) error {
+ if q.UserID == userWithStamp.ID {
+ q.Result = userWithStamp
+ return nil
+ }
+ return app.ErrNotFound
+ })
+
+ server := mock.NewServer()
+ server.Use(middlewares.User())
+ status, response := server.
+ OnTenant(mock.DemoTenant).
+ AddCookie(web.CookieAuthName, token).
+ Execute(func(c *web.Context) error {
+ return c.String(http.StatusOK, c.User().Name)
+ })
+
+ Expect(status).Equals(http.StatusOK)
+ Expect(response.Body.String()).Equals("Jon Snow")
+}
+
+// TestUser_SecurityStamp_Mismatch verifies that a browser session is redirected to
+// /signin when the stamp in the JWT no longer matches the DB stamp (e.g. after a
+// role change or an OAuth provider allowed-roles update).
+func TestUser_SecurityStamp_Mismatch(t *testing.T) {
+ RegisterT(t)
+
+ userWithStamp := &entity.User{
+ ID: mock.JonSnow.ID,
+ Name: mock.JonSnow.Name,
+ Email: mock.JonSnow.Email,
+ Tenant: mock.DemoTenant,
+ Status: enum.UserActive,
+ Role: enum.RoleAdministrator,
+ SecurityStamp: "stamp-new", // DB has been updated
+ Providers: mock.JonSnow.Providers,
+ }
+
+ // Token carries the OLD stamp
+ token, _ := jwt.Encode(jwt.FiderClaims{
+ UserID: userWithStamp.ID,
+ UserName: userWithStamp.Name,
+ SecurityStamp: "stamp-old",
+ })
+
+ bus.AddHandler(func(ctx context.Context, q *query.GetUserByID) error {
+ if q.UserID == userWithStamp.ID {
+ q.Result = userWithStamp
+ return nil
+ }
+ return app.ErrNotFound
+ })
+
+ server := mock.NewServer()
+ server.Use(middlewares.User())
+ status, response := server.
+ OnTenant(mock.DemoTenant).
+ WithURL("http://demo.test.fider.io/settings").
+ AddCookie(web.CookieAuthName, token).
+ Execute(func(c *web.Context) error {
+ return c.String(http.StatusOK, c.User().Name)
+ })
+
+ // Browser request: should redirect to /signin with the current path as return URL
+ Expect(status).Equals(http.StatusTemporaryRedirect)
+ Expect(response.Header().Get("Location")).ContainsSubstring("/signin")
+ Expect(response.Header().Get("Set-Cookie")).ContainsSubstring(web.CookieAuthName + "=;")
+}
+
+// TestUser_SecurityStamp_Mismatch_AJAX verifies that an AJAX request receives a 401
+// JSON response (not a redirect) when the security stamp is stale.
+func TestUser_SecurityStamp_Mismatch_AJAX(t *testing.T) {
+ RegisterT(t)
+
+ userWithStamp := &entity.User{
+ ID: mock.JonSnow.ID,
+ Name: mock.JonSnow.Name,
+ Email: mock.JonSnow.Email,
+ Tenant: mock.DemoTenant,
+ Status: enum.UserActive,
+ Role: enum.RoleAdministrator,
+ SecurityStamp: "stamp-new",
+ Providers: mock.JonSnow.Providers,
+ }
+
+ token, _ := jwt.Encode(jwt.FiderClaims{
+ UserID: userWithStamp.ID,
+ UserName: userWithStamp.Name,
+ SecurityStamp: "stamp-old",
+ })
+
+ bus.AddHandler(func(ctx context.Context, q *query.GetUserByID) error {
+ if q.UserID == userWithStamp.ID {
+ q.Result = userWithStamp
+ return nil
+ }
+ return app.ErrNotFound
+ })
+
+ server := mock.NewServer()
+ server.Use(middlewares.User())
+ status, _ := server.
+ OnTenant(mock.DemoTenant).
+ AddHeader("Accept", "application/json").
+ AddCookie(web.CookieAuthName, token).
+ Execute(func(c *web.Context) error {
+ return c.String(http.StatusOK, c.User().Name)
+ })
+
+ // AJAX request: should get a 401 JSON, not a redirect
+ Expect(status).Equals(http.StatusUnauthorized)
+}
+
+// TestUser_SecurityStamp_EmptyInToken verifies backward compatibility:
+// old tokens without a stamp embedded must still be accepted.
+func TestUser_SecurityStamp_EmptyInToken(t *testing.T) {
+ RegisterT(t)
+
+ userWithStamp := &entity.User{
+ ID: mock.JonSnow.ID,
+ Name: mock.JonSnow.Name,
+ Email: mock.JonSnow.Email,
+ Tenant: mock.DemoTenant,
+ Status: enum.UserActive,
+ Role: enum.RoleAdministrator,
+ SecurityStamp: "stamp-in-db",
+ Providers: mock.JonSnow.Providers,
+ }
+
+ // Old token: no SecurityStamp field
+ token, _ := jwt.Encode(jwt.FiderClaims{
+ UserID: userWithStamp.ID,
+ UserName: userWithStamp.Name,
+ // SecurityStamp deliberately omitted (simulates pre-stamp tokens)
+ })
+
+ bus.AddHandler(func(ctx context.Context, q *query.GetUserByID) error {
+ if q.UserID == userWithStamp.ID {
+ q.Result = userWithStamp
+ return nil
+ }
+ return app.ErrNotFound
+ })
+
+ server := mock.NewServer()
+ server.Use(middlewares.User())
+ status, response := server.
+ OnTenant(mock.DemoTenant).
+ AddCookie(web.CookieAuthName, token).
+ Execute(func(c *web.Context) error {
+ return c.String(http.StatusOK, c.User().Name)
+ })
+
+ // Old tokens without a stamp must still work (backward compatible)
+ Expect(status).Equals(http.StatusOK)
+ Expect(response.Body.String()).Equals("Jon Snow")
+}
+
diff --git a/app/models/cmd/user.go b/app/models/cmd/user.go
index 81e25f1dd..5bae7c0df 100644
--- a/app/models/cmd/user.go
+++ b/app/models/cmd/user.go
@@ -54,3 +54,5 @@ type UpdateCurrentUser struct {
AvatarType enum.AvatarType
Avatar *dto.ImageUpload
}
+
+type RotateAllUserSecurityStamps struct {}
diff --git a/app/models/entity/user.go b/app/models/entity/user.go
index 9f3393865..f9897c7bf 100644
--- a/app/models/entity/user.go
+++ b/app/models/entity/user.go
@@ -19,6 +19,7 @@ type User struct {
AvatarURL string `json:"avatarURL,omitempty"`
Status enum.UserStatus `json:"status"`
IsTrusted bool `json:"isTrusted"`
+ SecurityStamp string `json:"-"`
}
// HasProvider returns true if current user has registered with given provider
diff --git a/app/pkg/jwt/jwt.go b/app/pkg/jwt/jwt.go
index 24e333170..b934a990d 100644
--- a/app/pkg/jwt/jwt.go
+++ b/app/pkg/jwt/jwt.go
@@ -27,10 +27,11 @@ const (
// FiderClaims represents what goes into JWT tokens
type FiderClaims struct {
- UserID int `json:"user/id"`
- UserName string `json:"user/name"`
- UserEmail string `json:"user/email"`
- Origin string `json:"origin"`
+ UserID int `json:"user/id"`
+ UserName string `json:"user/name"`
+ UserEmail string `json:"user/email"`
+ Origin string `json:"origin"`
+ SecurityStamp string `json:"user/security_stamp,omitempty"`
Metadata
}
diff --git a/app/pkg/web/util/webutil.go b/app/pkg/web/util/webutil.go
index 863d0554c..e1dff7611 100644
--- a/app/pkg/web/util/webutil.go
+++ b/app/pkg/web/util/webutil.go
@@ -13,10 +13,11 @@ import (
func encode(user *entity.User) string {
token, err := jwt.Encode(jwt.FiderClaims{
- UserID: user.ID,
- UserName: user.Name,
- UserEmail: user.Email,
- Origin: jwt.FiderClaimsOriginUI,
+ UserID: user.ID,
+ UserName: user.Name,
+ UserEmail: user.Email,
+ Origin: jwt.FiderClaimsOriginUI,
+ SecurityStamp: user.SecurityStamp,
Metadata: jwt.Metadata{
ExpiresAt: jwt.Time(time.Now().Add(365 * 24 * time.Hour)),
},
diff --git a/app/services/sqlstore/dbEntities/user.go b/app/services/sqlstore/dbEntities/user.go
index b255f3ca5..15d056cf6 100644
--- a/app/services/sqlstore/dbEntities/user.go
+++ b/app/services/sqlstore/dbEntities/user.go
@@ -22,6 +22,7 @@ type User struct {
AvatarType sql.NullInt64 `db:"avatar_type"`
AvatarBlobKey sql.NullString `db:"avatar_bkey"`
IsTrusted sql.NullBool `db:"is_trusted"`
+ SecurityStamp sql.NullString `db:"security_stamp"`
Providers []*UserProvider
}
@@ -64,6 +65,7 @@ func (u *User) ToModel(ctx context.Context) *entity.User {
AvatarBlobKey: u.AvatarBlobKey.String,
AvatarURL: avatarURL,
IsTrusted: u.IsTrusted.Bool,
+ SecurityStamp: u.SecurityStamp.String,
}
if u.Providers != nil {
diff --git a/app/services/sqlstore/postgres/oauth.go b/app/services/sqlstore/postgres/oauth.go
index 409a5e93d..2f5e52b1c 100644
--- a/app/services/sqlstore/postgres/oauth.go
+++ b/app/services/sqlstore/postgres/oauth.go
@@ -91,12 +91,20 @@ func saveCustomOAuthConfig(ctx context.Context, c *cmd.SaveCustomOAuthConfig) er
c.Scope, c.JSONUserIDPath, c.JSONUserNamePath,
c.JSONUserEmailPath, c.JSONUserRolesPath, c.AllowedRoles, c.Logo.BlobKey)
} else {
+ // Detect if allowed_roles is being changed. If so, we must rotate all
+ // user security stamps so that currently-logged-in users are forced to
+ // re-authenticate and have their OAuth roles re-evaluated.
+ var prevAllowedRoles string
+ _ = trx.Scalar(&prevAllowedRoles,
+ "SELECT COALESCE(allowed_roles, '') FROM oauth_providers WHERE tenant_id = $1 AND id = $2",
+ tenant.ID, c.ID)
+
query := `
UPDATE oauth_providers
SET display_name = $3, status = $4, client_id = $5, client_secret = $6,
- authorize_url = $7, profile_url = $8, token_url = $9, scope = $10,
- json_user_id_path = $11, json_user_name_path = $12, json_user_email_path = $13,
- json_user_roles_path = $14, allowed_roles = $15, logo_bkey = $16, is_trusted = $17
+ authorize_url = $7, profile_url = $8, token_url = $9, scope = $10,
+ json_user_id_path = $11, json_user_name_path = $12, json_user_email_path = $13,
+ json_user_roles_path = $14, allowed_roles = $15, logo_bkey = $16, is_trusted = $17
WHERE tenant_id = $1 AND id = $2`
_, err = trx.Execute(query, tenant.ID, c.ID,
@@ -104,6 +112,16 @@ func saveCustomOAuthConfig(ctx context.Context, c *cmd.SaveCustomOAuthConfig) er
c.AuthorizeURL, c.ProfileURL, c.TokenURL,
c.Scope, c.JSONUserIDPath, c.JSONUserNamePath,
c.JSONUserEmailPath, c.JSONUserRolesPath, c.AllowedRoles, c.Logo.BlobKey, c.IsTrusted)
+
+ if err == nil && prevAllowedRoles != c.AllowedRoles {
+ // Rotate stamps inside the same transaction so the change is atomic.
+ if _, stampErr := trx.Execute(
+ "UPDATE users SET security_stamp = md5(random()::text || id::text) WHERE tenant_id = $1",
+ tenant.ID,
+ ); stampErr != nil {
+ return errors.Wrap(stampErr, "failed to rotate security stamps after allowed_roles change")
+ }
+ }
}
if err != nil {
diff --git a/app/services/sqlstore/postgres/postgres.go b/app/services/sqlstore/postgres/postgres.go
index ea34d695a..67ae5cf9b 100644
--- a/app/services/sqlstore/postgres/postgres.go
+++ b/app/services/sqlstore/postgres/postgres.go
@@ -104,6 +104,7 @@ func (s Service) Init() {
bus.AddHandler(getAllUsers)
bus.AddHandler(getAllUsersNames)
bus.AddHandler(searchUsers)
+ bus.AddHandler(rotateAllUserSecurityStamps)
bus.AddHandler(createTenant)
bus.AddHandler(getFirstTenant)
diff --git a/app/services/sqlstore/postgres/user.go b/app/services/sqlstore/postgres/user.go
index d765927a5..3f064048e 100644
--- a/app/services/sqlstore/postgres/user.go
+++ b/app/services/sqlstore/postgres/user.go
@@ -14,10 +14,17 @@ import (
"github.com/getfider/fider/app/models/query"
"github.com/getfider/fider/app/pkg/dbx"
"github.com/getfider/fider/app/pkg/errors"
+ "github.com/getfider/fider/app/pkg/rand"
"github.com/getfider/fider/app/services/sqlstore/dbEntities"
"github.com/lib/pq"
)
+// generateSecurityStamp creates a new random security stamp for a user.
+// Rotating the stamp invalidates all existing sessions for that user.
+func generateSecurityStamp() string {
+ return rand.String(64)
+}
+
func countUsers(ctx context.Context, q *query.CountUsers) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
var count int
@@ -33,8 +40,8 @@ func countUsers(ctx context.Context, q *query.CountUsers) error {
func blockUser(ctx context.Context, c *cmd.BlockUser) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
if _, err := trx.Execute(
- "UPDATE users SET status = $3 WHERE id = $1 AND tenant_id = $2",
- c.UserID, tenant.ID, enum.UserBlocked,
+ "UPDATE users SET status = $3, security_stamp = $4 WHERE id = $1 AND tenant_id = $2",
+ c.UserID, tenant.ID, enum.UserBlocked, generateSecurityStamp(),
); err != nil {
return errors.Wrap(err, "failed to block user")
}
@@ -45,8 +52,8 @@ func blockUser(ctx context.Context, c *cmd.BlockUser) error {
func unblockUser(ctx context.Context, c *cmd.UnblockUser) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
if _, err := trx.Execute(
- "UPDATE users SET status = $3 WHERE id = $1 AND tenant_id = $2",
- c.UserID, tenant.ID, enum.UserActive,
+ "UPDATE users SET status = $3, security_stamp = $4 WHERE id = $1 AND tenant_id = $2",
+ c.UserID, tenant.ID, enum.UserActive, generateSecurityStamp(),
); err != nil {
return errors.Wrap(err, "failed to unblock user")
}
@@ -166,8 +173,8 @@ func userSubscribedTo(ctx context.Context, q *query.UserSubscribedTo) error {
func changeUserRole(ctx context.Context, c *cmd.ChangeUserRole) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
- cmd := "UPDATE users SET role = $3 WHERE id = $1 AND tenant_id = $2"
- _, err := trx.Execute(cmd, c.UserID, tenant.ID, c.Role)
+ cmd := "UPDATE users SET role = $3, security_stamp = $4 WHERE id = $1 AND tenant_id = $2"
+ _, err := trx.Execute(cmd, c.UserID, tenant.ID, c.Role, generateSecurityStamp())
if err != nil {
return errors.Wrap(err, "failed to change user's role")
}
@@ -237,11 +244,13 @@ func registerUser(ctx context.Context, c *cmd.RegisterUser) error {
now := time.Now()
c.User.Status = enum.UserActive
c.User.Email = strings.ToLower(strings.TrimSpace(c.User.Email))
+ stamp := generateSecurityStamp()
if err := trx.Get(&c.User.ID,
- "INSERT INTO users (name, email, created_at, tenant_id, role, status, avatar_type, avatar_bkey) VALUES ($1, $2, $3, $4, $5, $6, $7, '') RETURNING id",
- c.User.Name, c.User.Email, now, tenant.ID, c.User.Role, enum.UserActive, enum.AvatarTypeGravatar); err != nil {
+ "INSERT INTO users (name, email, created_at, tenant_id, role, status, avatar_type, avatar_bkey, security_stamp) VALUES ($1, $2, $3, $4, $5, $6, $7, '', $8) RETURNING id",
+ c.User.Name, c.User.Email, now, tenant.ID, c.User.Role, enum.UserActive, enum.AvatarTypeGravatar, stamp); err != nil {
return errors.Wrap(err, "failed to register new user")
}
+ c.User.SecurityStamp = stamp
for _, provider := range c.User.Providers {
cmd := "INSERT INTO user_providers (tenant_id, user_id, provider, provider_uid, created_at) VALUES ($1, $2, $3, $4, $5)"
@@ -270,8 +279,8 @@ func updateCurrentUser(ctx context.Context, c *cmd.UpdateCurrentUser) error {
if c.Avatar.Remove {
c.Avatar.BlobKey = ""
}
- cmd := "UPDATE users SET name = $3, avatar_type = $4, avatar_bkey = $5 WHERE id = $1 AND tenant_id = $2"
- _, err := trx.Execute(cmd, user.ID, tenant.ID, c.Name, c.AvatarType, c.Avatar.BlobKey)
+ cmd := "UPDATE users SET name = $3, avatar_type = $4, avatar_bkey = $5, security_stamp = $6 WHERE id = $1 AND tenant_id = $2"
+ _, err := trx.Execute(cmd, user.ID, tenant.ID, c.Name, c.AvatarType, c.Avatar.BlobKey, generateSecurityStamp())
if err != nil {
return errors.Wrap(err, "failed to update user")
}
@@ -328,7 +337,7 @@ func getAllUsers(ctx context.Context, q *query.GetAllUsers) error {
return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
var users []*dbEntities.User
err := trx.Select(&users, `
- SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey
+ SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted, security_stamp
FROM users
WHERE tenant_id = $1
AND status != $2
@@ -370,7 +379,7 @@ func getAllUsersNames(ctx context.Context, q *query.GetAllUsersNames) error {
func queryUser(ctx context.Context, trx *dbx.Trx, filter string, args ...any) (*entity.User, error) {
user := dbEntities.User{}
- sql := fmt.Sprintf("SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted FROM users WHERE status != %d AND ", enum.UserDeleted)
+ sql := fmt.Sprintf("SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted, security_stamp FROM users WHERE status != %d AND ", enum.UserDeleted)
err := trx.Get(&user, sql+filter, args...)
if err != nil {
return nil, err
@@ -397,9 +406,9 @@ func searchUsers(ctx context.Context, q *query.SearchUsers) error {
}
baseQuery := `
- SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted
- FROM users
- WHERE tenant_id = $1 AND status != $2
+ SELECT id, name, email, tenant_id, role, status, avatar_type, avatar_bkey, is_trusted, security_stamp
+ FROM users
+ WHERE tenant_id = $1 AND status != $2
`
args := []interface{}{tenant.ID, enum.UserDeleted}
argIndex := 3
@@ -486,3 +495,16 @@ func searchUsers(ctx context.Context, q *query.SearchUsers) error {
return nil
})
}
+
+func rotateAllUserSecurityStamps(ctx context.Context, c *cmd.RotateAllUserSecurityStamps) error {
+ return using(ctx, func(trx *dbx.Trx, tenant *entity.Tenant, user *entity.User) error {
+ _, err := trx.Execute(
+ "UPDATE users SET security_stamp = md5(random()::text || id::text) WHERE tenant_id = $1",
+ tenant.ID,
+ )
+ if err != nil {
+ return errors.Wrap(err, "failed to rotate all user security stamps")
+ }
+ return nil
+ })
+}
diff --git a/migrations/202603201300_add_security_stamp.sql b/migrations/202603201300_add_security_stamp.sql
new file mode 100644
index 000000000..11e0729aa
--- /dev/null
+++ b/migrations/202603201300_add_security_stamp.sql
@@ -0,0 +1,2 @@
+ALTER TABLE users ADD COLUMN security_stamp VARCHAR(64) NOT NULL DEFAULT '';
+UPDATE users SET security_stamp = md5(random()::text || id::text || tenant_id::text);
diff --git a/public/services/http.ts b/public/services/http.ts
index f17d2e011..36d678e38 100644
--- a/public/services/http.ts
+++ b/public/services/http.ts
@@ -1,4 +1,4 @@
-import { analytics, notify, truncate } from "@fider/services"
+import { analytics, notify, truncate, Fider } from "@fider/services"
export interface ErrorItem {
field?: string
@@ -28,6 +28,16 @@ async function toResult<T>(response: Response): Promise<Result<T>> {
if (response.status === 500) {
notify.error("An unexpected error occurred while processing your request.")
} else if (response.status === 401) {
+ // If the user was authenticated but received a 401 it means their session was
+ // invalidated (e.g. security stamp rotated after an OAuth allowed-roles change).
+ // Redirect to /signin so they re-authenticate and the role check runs again.
+ if (Fider.session.isAuthenticated) {
+ const redirect = encodeURIComponent(window.location.pathname + window.location.search)
+ window.location.href = `/signin?redirect=${redirect}`
+ // Return a never-resolving promise so no further code runs while navigating.
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ return new Promise<Result<T>>(() => {})
+ }
notify.error("You need to be authenticated to perform this operation.")
} else if (response.status === 403) {
notify.error("You are not authorized to perform this operation.")