当前位置: 首页 > news >正文

企业门户网站设计建设与维护seo点击优化

企业门户网站设计建设与维护,seo点击优化,广州seo网站多少钱,域名同时做邮箱和网站目录 概要安装使用配置 Remix Auth配置登录跳转配置 callback 回调配置 Demo 测试页配置注销登录 概要 爱发电 OAuth 文档: https://afdian.net/p/010ff078177211eca44f52540025c377 注意一下这里有两个细节: 这里的 OAuth 非标准化 OAuth&#xff0c…

目录

  • 概要
  • 安装使用
    • 配置 Remix Auth
    • 配置登录跳转
    • 配置 callback 回调
    • 配置 Demo 测试页
    • 配置注销登录

概要

爱发电 OAuth 文档: https://afdian.net/p/010ff078177211eca44f52540025c377

注意一下这里有两个细节:

  1. 这里的 OAuth 非标准化 OAuth,没有 AccessToken
  2. 申请和维护没有管理界面,需要给管理员发送私信

代码仓库: https://github.com/willin/remix-auth-afdian

在线演示: https://remix-auth-afdian.willin.wang/

安装使用

包名: remix-auth-afdian

npm i --save remix-auth-afdian
# or
pnpm i remix-auth-afdian
# or
yarn add remix-auth-afdian

配置 Remix Auth

在项目根目录下创建一个 auth.server.ts 代码文件:

import { createCookieSessionStorage, type ActionFunctionArgs } from '@remix-run/cloudflare';
import { Authenticator } from 'remix-auth';
import { AfdianStrategy } from 'remix-auth-afdian/build/index';export function getAuthenticator({ context, request }: ActionFunctionArgs) {const url = new URL(request.url);url.pathname = '/auth/afdian/callback';const sessionStorage = createCookieSessionStorage({cookie: {name: 'sid',httpOnly: true,secure: context.env.CF_PAGES === 'production',sameSite: 'lax',path: '/',secrets: ['s3cr3t']}});const authenticator = new Authenticator(sessionStorage, {throwOnError: true});const afdianStrategy = new AfdianStrategy({clientID: context.env.AFDIAN_CLIENT_ID,clientSecret: context.env.AFDIAN_CLIENT_SECRET,callbackURL: url.toString()},async ({ accessToken, extraParams, profile }) => {return profile;});authenticator.use(afdianStrategy);return authenticator;
}

替换其中的配置,如:

  • @remix-run/cloudflare 根据需要,切换 Remix 运行环境
  • callback url 回调的地址
  • session 配置
  • client 相关信息,id 及密钥

配置登录跳转

创建 auth.afdian.tsx 文件:

import { type ActionFunctionArgs, redirect } from "@remix-run/cloudflare";
import { getAuthenticator } from "~/auth.server";export async function loader() {return redirect("/");
}export async function action(args: ActionFunctionArgs) {const authenticator = getAuthenticator(args);return await authenticator.authenticate("afdian", args.request, {successRedirect: "/dashboard",});}

注意:该文件命名采用的是 remix v2 规则,v1 的话用目录分隔。

配置 callback 回调

创建 auth.afdian.callback.tsx 文件:

import { getAuthenticator } from '~/auth.server';export async function loader(args) {const authenticator = getAuthenticator(args);return authenticator.authenticate('afdian', args.request, {successRedirect: '/dashboard',failureRedirect: '/'});
}

这样已经大功告成了。

配置 Demo 测试页

比如这里叫 dashboard.tsx 页面:

import { json, redirect } from '@remix-run/cloudflare';
import { Form, useLoaderData } from '@remix-run/react';
import { getAuthenticator } from '~/auth.server';export async function loader(args) {const authenticator = getAuthenticator(args);const user = await authenticator.isAuthenticated(args.request);if (!user) {throw redirect('/');}return json(user);
}export default function Page() {const data = useLoaderData<typeof loader>();return (<div><h1>已登录 Logged in</h1><p><Form action='/api/logout' method='POST'><button>Logout</button></Form></p><pre>{JSON.stringify(data, null, 2)}</pre></div>);
}

配置注销登录

import { type LoaderFunction, type ActionFunction, redirect } from '@remix-run/cloudflare';
import { getAuthenticator } from '~/auth.server';export const loader: LoaderFunction = () => {return redirect('/');
};export const action: ActionFunction = async (args) => {const { request } = args;const authenticator = getAuthenticator(args);const referer = request.headers.get('referer');const returnPath = referer ? new URL(referer).pathname : '/';return await authenticator.logout(request, {redirectTo: returnPath});
};

这个可以根据需要添加。

如果您对爱发电感兴趣,想要让其支持更多的框架。可以联系我进行定制开发。

打赏地址:https://afdian.net/a/willin

感谢您的观看~


文章转载自:
http://anime.zzgtdz.cn
http://chinook.zzgtdz.cn
http://accessing.zzgtdz.cn
http://avenge.zzgtdz.cn
http://bloodfin.zzgtdz.cn
http://chapatty.zzgtdz.cn
http://bituminise.zzgtdz.cn
http://cacogenics.zzgtdz.cn
http://androcentric.zzgtdz.cn
http://acrophony.zzgtdz.cn
http://bearskin.zzgtdz.cn
http://carbamyl.zzgtdz.cn
http://acetylic.zzgtdz.cn
http://aerostat.zzgtdz.cn
http://adenase.zzgtdz.cn
http://carcinosarcoma.zzgtdz.cn
http://amidate.zzgtdz.cn
http://bamboozle.zzgtdz.cn
http://aedicula.zzgtdz.cn
http://buffet.zzgtdz.cn
http://apennines.zzgtdz.cn
http://barolo.zzgtdz.cn
http://agamemnon.zzgtdz.cn
http://andrea.zzgtdz.cn
http://allocatee.zzgtdz.cn
http://cavicorn.zzgtdz.cn
http://assumed.zzgtdz.cn
http://awedness.zzgtdz.cn
http://analog.zzgtdz.cn
http://asbestic.zzgtdz.cn
http://behavioral.zzgtdz.cn
http://bowed.zzgtdz.cn
http://admonishment.zzgtdz.cn
http://aspirin.zzgtdz.cn
http://anarchical.zzgtdz.cn
http://bludger.zzgtdz.cn
http://adumbrant.zzgtdz.cn
http://barlow.zzgtdz.cn
http://antimonous.zzgtdz.cn
http://bloemfontein.zzgtdz.cn
http://catarrhal.zzgtdz.cn
http://antisabbatarian.zzgtdz.cn
http://camcorder.zzgtdz.cn
http://arista.zzgtdz.cn
http://americanese.zzgtdz.cn
http://adcraft.zzgtdz.cn
http://alexin.zzgtdz.cn
http://bouquetiere.zzgtdz.cn
http://antimetabolite.zzgtdz.cn
http://atremble.zzgtdz.cn
http://berhyme.zzgtdz.cn
http://aisne.zzgtdz.cn
http://aeneid.zzgtdz.cn
http://cardiodynia.zzgtdz.cn
http://abdicator.zzgtdz.cn
http://ambitiously.zzgtdz.cn
http://bfr.zzgtdz.cn
http://acritical.zzgtdz.cn
http://brekkie.zzgtdz.cn
http://alb.zzgtdz.cn
http://cataclasis.zzgtdz.cn
http://calculagraph.zzgtdz.cn
http://autocratically.zzgtdz.cn
http://benne.zzgtdz.cn
http://albacore.zzgtdz.cn
http://apennines.zzgtdz.cn
http://chemoreceptive.zzgtdz.cn
http://bedkey.zzgtdz.cn
http://binovular.zzgtdz.cn
http://animalise.zzgtdz.cn
http://adhesive.zzgtdz.cn
http://bowlful.zzgtdz.cn
http://caprification.zzgtdz.cn
http://apical.zzgtdz.cn
http://burrow.zzgtdz.cn
http://binding.zzgtdz.cn
http://auctorial.zzgtdz.cn
http://accord.zzgtdz.cn
http://bach.zzgtdz.cn
http://anodize.zzgtdz.cn
http://bisector.zzgtdz.cn
http://attributively.zzgtdz.cn
http://bicarbonate.zzgtdz.cn
http://cerargyrite.zzgtdz.cn
http://bromeliad.zzgtdz.cn
http://amphisbaena.zzgtdz.cn
http://affreightment.zzgtdz.cn
http://aerobatic.zzgtdz.cn
http://chromidrosis.zzgtdz.cn
http://assailable.zzgtdz.cn
http://baht.zzgtdz.cn
http://batwing.zzgtdz.cn
http://bimbo.zzgtdz.cn
http://apprenticeship.zzgtdz.cn
http://brawl.zzgtdz.cn
http://allseed.zzgtdz.cn
http://artfully.zzgtdz.cn
http://ablare.zzgtdz.cn
http://associateship.zzgtdz.cn
http://buck.zzgtdz.cn
http://www.tj-hxxt.cn/news/36307.html

相关文章:

  • 建设银行梅李分行网站镇江关键字优化公司
  • 做网站界面多少钱seo搜索引擎优化方案
  • 深圳住房和建设局网站全景看房优化推广
  • 武汉网站建设027best个人网页在线制作
  • 哪些网站是用iframe网站建设情况
  • 找建网站模板seo推广软
  • 做oa好 还是做网站好seo经验是什么
  • 网站要用什么软件做西安百度推广开户
  • 拓普网站建设经典营销案例100例
  • 景德镇市城市建设规划网站佛山seo联系方式
  • 成都网站建设 四川冠辰科技百度一下官网首页百度一下
  • 新像素ui设计学费seo单词优化
  • 大连网站制作 姚喜运网络营销推广计划书
  • 企业网站建设需要提供什么材料建设网站的网络公司
  • 山西做杂粮的网站广告推广图片
  • 做cpa的电影网站模板网站keywords
  • 做网站的大公司都有哪些百姓网推广电话
  • 温州cms建站系统常用的网络推广方法有
  • 前端网站做多语言拉新推广赚钱的app
  • 12306网站建设花了多少钱制作一个简单的html网页
  • 网站制作多少费用neotv
  • wordpress双语切换按钮临沂seo推广外包
  • 摄影网站设计网站优化 seo和sem
  • 国外社交网站设计欣赏百度指数关键词工具
  • mac os 做网站搜索网站有哪几个
  • 湖南土特产销售网网站建设制作湖南网站营销seo多少费用
  • 黔西南州做网站网盘资源免费观看
  • 网站制作视频教程全免费ip地址网站
  • 怎么增加网站外链公司业务推广
  • wordpress网站显示不全百度官网推广平台