blob: 308fd706087eb5df1b4df4ea82f430fd3b6f0203 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/bin/sh
set -eu
service=$1
email=${2:-$(git config fetchemail.imapUser)}
generate() {
openssl rand -base64 33
}
copy() {
printf '%s' "$1" | pbcopy
}
discogs() {
echo 'Submitting form...'
curl -Ss -X POST \
-F "email=${email}" -F 'Action.EmailResetInstructions=submit' \
'https://www.discogs.com/users/forgot_password' \
>/dev/null
echo 'Waiting for email...'
url=$(
git fetch-email -i -M Trash \
-F 'noreply@discogs.com' -T "${email}" \
-S 'Discogs Account Password Reset Instructions' |
sed -n 's/^To proceed, follow the instructions here: \(.*\)/\1/p'
)
echo 'Fetching token...'
token=$(curl -ISs --url "${url}" | sed -n 's/.*[?]token=\([^&]*\).*/\1/p')
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST \
-F "token=${token}" \
-F "password0=${password}" -F "password1=${password}" \
-F 'Action.ChangePassword=submit' \
'https://www.discogs.com/users/forgot_password' \
>/dev/null
copy "${password}"
open 'https://discogs.com/login'
}
lobsters() {
: ${lobstersBase:=https://lobste.rs}
: ${lobstersFrom:=nobody@lobste.rs}
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss "${lobstersBase}/login/forgot_password" |
sed -n 's/.*name="authenticity_token" value="\([^"]*\)".*/\1/p'
)
echo 'Submitting form...'
curl -Ss -X POST \
-F "authenticity_token=${csrf}" \
-F "email=${email}" -F 'commit=submit' \
"${lobstersBase}/login/reset_password" \
>/dev/null
echo 'Waiting for email...'
token=$(
git fetch-email -i -M Trash \
-F "${lobstersFrom}" -T "${email}" \
-S 'Reset your password' |
sed -n 's|^https://.*[?]token=\(.*\)|\1|p'
)
echo 'Fetching CSRF token...'
csrf=$(
curl -Ss "${lobstersBase}/login/set_new_password?token=${token}" |
sed -n 's/.*name="authenticity_token" value="\([^"]*\)".*/\1/p'
)
password=$(generate)
echo 'Setting password...'
curl -Ss -X POST \
-F "authenticity_token=${csrf}" -F "token=${token}" \
-F "password=${password}" -F "password_confirmation=${password}" \
-F 'commit=submit' \
"${lobstersBase}/login/set_new_password" \
>/dev/null
copy "${password}"
open "${lobstersBase}/login"
}
tildenews() {
lobstersBase='https://tilde.news'
lobstersFrom='nobody@tilde.news'
lobsters
}
$service
|