kat

kat / atwall.pl

Last active 3 days ago

Like 0
atwall.pl Raw
1use v5.44.0;
2use strict;
3use warnings;
4
5use Mojolicious::Lite -signatures;
6use Mojo::ATProto::OAuth;
7
8my $oauth = Mojo::ATProto::OAuth->new_localhost(
9 callback_url => "http://127.0.0.1:3000/callback",
10 scopes => ["atproto", "transition:generic"],
11 store => ["SQLite" => "file:/tmp/test.db?wal_mode=1"]
12);
13
14get "/" => sub ($c) {
15 $c->render(text => "welcome to the atwall!<br><br>log in at <a href='/login'>/login</a>");
16};
17
18get "/login" => sub ($c) {
19 my $handle_or_did = "katproto.girlonthemoon.xyz";
20 my $redirect_url = $oauth->start_auth_flow(identifier => $handle_or_did);
21
22 $c->redirect_to($redirect_url);
23};
24
25get "/callback" => sub ($c) {
26 my $params = $c->req->params->to_hash;
27 my $session = $oauth->process_callback($params);
28 $c->render(text => "you are logged in as $session->{handle} ($session->{account_did})\n");
29};
30
31app->start;