Renaming manifest

main
Denny Cave 2023-07-22 00:07:49 -05:00
parent 05145b7b5a
commit a9584b06d9
4 changed files with 178 additions and 78 deletions

View File

@ -1,78 +0,0 @@
type: update
name: Instant Login
description: Login to your WordPress site as an administrator with a single click.
targetNodes:
nodeGroup: cp
onInstall:
cmd [cp]:
- cd /var/www/webroot/ROOT/
- wp package install aaemnnosttv/wp-cli-login-command
- wp login install --yes --activate
setGlobals:
userToLoginAs: 1
actions:
instant_login:
#log: ${placeholders}
cmd [cp]:
- cd /var/www/webroot/ROOT/
- wp login create ${globals.userToLoginAs} --url-only
#- user=$(wp user list --field=user_login --format=csv)
#- wp login create $user --url-only
return:
type: success
message: |
[Click to login](${response.out})
*(Link will expire in 15 minutes)*
save_config:
#empty method to allow userToLoginAs to save
#log: ${placeholders}
# lookup user that was entered
cmd [cp]:
- cd /var/www/webroot/ROOT/
- user=$(wp user get ${settings.userToLoginAs} --field=ID)
# see if number (user ID) returned or not. Return 1 if yes.
- re='^[0-9]+$'
- if ! [[ $user =~ $re ]]; then echo 0; else echo 1; fi
#check if the user was found
# returns ID if so
# returns 'Error: Invalid user ID, email or login: '24342''
if (response.out == 0):
script: |
return {"result": "error", "message": "User not found. Try again."}
else:
- setGlobals:
userToLoginAs: ${settings.userToLoginAs}
- script: |
return {"result": "success", "message": "User saved!"}
settings:
configure:
fields:
- type: string
name: userToLoginAs
caption: User to login as
placeholder: Enter user ID, user email, or user login
buttons:
- caption: Instant Login
loadingText: Generating login...
confirmText: Generate a login link for the configured user? This will log you out of any existing sessions.
action: instant_login
- caption: Configure
action: save_config
settings: configure
# problem - only saves the user name/id/email on initial creation. Since adding custom code to save_config, it will not update with new user value after saving again
# tried to use setGlobals but doesn't seem like that works any better
#SOLUTION: Combine these two options into one button - the button shows the input form, filled out with the username that was previously used. Then upon saving, it checks to see if that's a real user and if so it generates the login for that user.

View File

@ -0,0 +1,43 @@
type: update
name: Instant Login
id: instant-login
description: Login to your WordPress site as an administrator with a single click.
targetNodes:
nodeGroup: cp
onInstall:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- wp package install aaemnnosttv/wp-cli-login-command
- mkdir -p /var/www/webroot/ROOT/wp-content/mu-plugins
- cd /var/www/webroot/ROOT/wp-content/mu-plugins
- wget https://raw.githubusercontent.com/aaemnnosttv/wp-cli-login-server/master/wp-cli-login-server.php
setGlobals:
userToLoginAs: 1
onUninstall:
cmd[${nodes.cp.master.id}]: rm -f /var/www/webroot/ROOT/wp-content/mu-plugins/wp-cli-login-server.php
actions:
instant_login:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
#- user=$(wp user list --field=user_login --role=administrator --format=csv --number=1)
- user=$(wp user list --field=ID --role=administrator --format=csv --number=1 --orderby=ID)
- wp login create $user --url-only
return:
type: success
message: |
[Click to login](${response.out})
*(Link will expire in 15 minutes)*
buttons:
- caption: Instant Login
loadingText: Generating login...
confirmText: Generate a login link for the first admin user? This will log you out of any existing sessions.
action: instant_login

View File

@ -0,0 +1,85 @@
type: update
name: Instant Login
description: Login to your WordPress site as an administrator with a single click.
targetNodes:
nodeGroup: cp
onInstall:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- wp package install aaemnnosttv/wp-cli-login-command
- mkdir -p /var/www/webroot/ROOT/wp-content/mu-plugins
- cd /var/www/webroot/ROOT/wp-content/mu-plugins
- wget https://raw.githubusercontent.com/aaemnnosttv/wp-cli-login-server/master/wp-cli-login-server.php
setGlobals:
userToLoginAs: 1
onUninstall:
cmd[${nodes.cp.master.id}]: rm -f /var/www/webroot/ROOT/wp-content/mu-plugins/wp-cli-login-server.php
actions:
instant_login:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- wp login create ${globals.userToLoginAs} --url-only
#- user=$(wp user list --field=user_login --format=csv)
#- wp login create $user --url-only
return:
type: success
message: |
[Click to login as user ${globals.userToLoginAs}](${response.out})
*(Link will expire in 15 minutes)*
save_config:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- user=$(wp user get ${settings.userToLoginAs} --field=ID)
# see if number (user ID) returned or not. Return 1 if yes.
- re='^[0-9]+$'
- if ! [[ $user =~ $re ]]; then echo 0; else echo 1; fi
#check if the user was found
# returns ID if so
# returns 'Error: Invalid user ID, email or login: '24342''
if (response.out == 0):
return:
type: error
message: User '${settings.userToLoginAs}' not found. Try again.
else:
setGlobals:
userToLoginAs: ${settings.userToLoginAs}
return:
type: success
message: |
settings.userToLoginAs: ${settings.userToLoginAs}
globals.userToLoginAs: ${globals.userToLoginAs}
settings:
configure:
fields:
- type: string
name: userToLoginAs
caption: User to login as
placeholder: Enter user ID, user email, or user login
buttons:
- caption: Instant Login
loadingText: Generating login...
confirmText: Generate a login link for the configured user? This will log you out of any existing sessions.
action: instant_login
- caption: Configure
action: save_config
settings: configure
# problem - only saves the user name/id/email on initial creation. Since adding custom code to save_config, it will not update with new user value after saving again
# tried to use setGlobals but doesn't seem like that works any better
#SOLUTION: Combine these two options into one button - the button shows the input form, filled out with the username that was previously used. Then upon saving, it checks to see if that's a real user and if so it generates the login for that user.

50
manifest.jps 100644
View File

@ -0,0 +1,50 @@
type: update
name: Instant Login
id: instant-login
description: Login to your WordPress site as an administrator with a single click.
targetNodes:
nodeGroup: cp
onInstall:
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- wp package install aaemnnosttv/wp-cli-login-command
- mkdir -p /var/www/webroot/ROOT/wp-content/mu-plugins
- cd /var/www/webroot/ROOT/wp-content/mu-plugins
- wget https://raw.githubusercontent.com/aaemnnosttv/wp-cli-login-server/master/wp-cli-login-server.php
setGlobals:
userToLoginAs: 1
onUninstall:
cmd[${nodes.cp.master.id}]: rm -f /var/www/webroot/ROOT/wp-content/mu-plugins/wp-cli-login-server.php
actions:
instant_login:
#log: ${placeholders}
cmd[${nodes.cp.master.id}]:
- cd /var/www/webroot/ROOT/
- wp login create ${globals.userToLoginAs} --url-only
#- user=$(wp user list --field=user_login --format=csv)
#- wp login create $user --url-only
return:
type: success
message: |
[Click to login as user ${globals.userToLoginAs}](${response.out})
*(Link will expire in 15 minutes)*
settings:
configure:
fields:
- type: string
name: userToLoginAs
caption: User to login as
placeholder: Enter user ID, user email, or user login
buttons:
- caption: Instant Login
loadingText: Generating login...
confirmText: Generate a login link for the configured user? This will log you out of any existing sessions.
action: instant_login