Skip to content

Commit

Permalink
Allow TOTP keys to be filterable
Browse files Browse the repository at this point in the history
Since the discussion in WordPress#389 seems to be on-going, the following should allow users of the plugin to decide how they would like to approach the encryption part.

Perhaps we can follow up with solutions after they've been implemented and debate further?
  • Loading branch information
pkevan authored Mar 21, 2023
1 parent c0eae28 commit 21234f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ public function user_two_factor_options( $user ) {
* @return string
*/
public function get_user_totp_key( $user_id ) {
return (string) get_user_meta( $user_id, self::SECRET_META_KEY, true );
$meta = (string) get_user_meta( $user_id, self::SECRET_META_KEY, true );
return apply_filters( 'two_factor_totp_get_user_totp_key', $meta, $user_id );
}

/**
Expand All @@ -432,6 +433,7 @@ public function get_user_totp_key( $user_id ) {
* @return boolean If the key was stored successfully.
*/
public function set_user_totp_key( $user_id, $key ) {
$key = apply_filters( 'two_factor_totp_set_user_totp_key', $key, $user_id );
return update_user_meta( $user_id, self::SECRET_META_KEY, $key );
}

Expand Down

0 comments on commit 21234f0

Please sign in to comment.