Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
Authy for WP
Commits
fed7cae7
Commit
fed7cae7
authored
Dec 01, 2012
by
Erick Hitter
Browse files
Better organization of main class's methods.
parent
ab689c33
Changes
1
Hide whitespace changes
Inline
Side-by-side
authy-wp.php
View file @
fed7cae7
...
...
@@ -281,64 +281,9 @@ class Authy_WP {
}
/**
* USER
SETTINGS PAGE
* USER
INFORMATION FUNCTIONS
*/
/**
*
*/
public
function
action_show_user_profile
()
{
$meta
=
$this
->
get_authy_data
(
get_current_user_id
()
);
?>
<h3>
Authy Two-factor Authentication
</h3>
<table
class=
"form-table"
>
<tr>
<th><label
for=
"phone"
>
Mobile number
</label></th>
<td>
<input
type=
"tel"
name=
"
<?php
echo
esc_attr
(
$this
->
users_key
);
?>
[phone]"
value=
"
<?php
echo
esc_attr
(
$meta
[
'phone'
]
);
?>
"
/>
</td>
</tr>
<tr>
<th><label
for=
"phone"
>
Country code
</label></th>
<td>
<input
type=
"text"
name=
"
<?php
echo
esc_attr
(
$this
->
users_key
);
?>
[country_code]"
value=
"
<?php
echo
esc_attr
(
$meta
[
'country_code'
]
);
?>
"
/>
</td>
</tr>
</table>
<?php
wp_nonce_field
(
$this
->
users_key
.
'edit_own'
,
$this
->
users_key
.
'[nonce]'
);
}
/**
*
*/
public
function
action_personal_options_update
(
$user_id
)
{
check_admin_referer
(
'update-user_'
.
$user_id
);
// Check if we have data to work with
$authy_data
=
isset
(
$_POST
[
$this
->
users_key
]
)
?
$_POST
[
$this
->
users_key
]
:
false
;
// Parse for nonce and API existence
if
(
is_array
(
$authy_data
)
&&
array_key_exists
(
'nonce'
,
$authy_data
)
&&
wp_verify_nonce
(
$authy_data
[
'nonce'
],
$this
->
users_key
.
'edit_own'
)
)
{
// Email address
$userdata
=
get_userdata
(
$user_id
);
if
(
is_object
(
$userdata
)
&&
!
is_wp_error
(
$userdata
)
)
$email
=
$userdata
->
data
->
user_email
;
else
$email
=
null
;
// Phone number
$phone
=
preg_replace
(
'#[^\d]#'
,
''
,
$authy_data
[
'phone'
]
);
$country_code
=
preg_replace
(
'#[^\d\+]#'
,
''
,
$authy_data
[
'country_code'
]
);
// Process information with Authy
$this
->
set_authy_data
(
$user_id
,
$email
,
$phone
,
$country_code
);
}
}
/**
*
*/
...
...
@@ -437,6 +382,66 @@ class Authy_WP {
return
false
;
}
/**
* USER SETTINGS PAGES
*/
/**
*
*/
public
function
action_show_user_profile
()
{
$meta
=
$this
->
get_authy_data
(
get_current_user_id
()
);
?>
<h3>
Authy Two-factor Authentication
</h3>
<table
class=
"form-table"
>
<tr>
<th><label
for=
"phone"
>
Mobile number
</label></th>
<td>
<input
type=
"tel"
name=
"
<?php
echo
esc_attr
(
$this
->
users_key
);
?>
[phone]"
value=
"
<?php
echo
esc_attr
(
$meta
[
'phone'
]
);
?>
"
/>
</td>
</tr>
<tr>
<th><label
for=
"phone"
>
Country code
</label></th>
<td>
<input
type=
"text"
name=
"
<?php
echo
esc_attr
(
$this
->
users_key
);
?>
[country_code]"
value=
"
<?php
echo
esc_attr
(
$meta
[
'country_code'
]
);
?>
"
/>
</td>
</tr>
</table>
<?php
wp_nonce_field
(
$this
->
users_key
.
'edit_own'
,
$this
->
users_key
.
'[nonce]'
);
}
/**
*
*/
public
function
action_personal_options_update
(
$user_id
)
{
check_admin_referer
(
'update-user_'
.
$user_id
);
// Check if we have data to work with
$authy_data
=
isset
(
$_POST
[
$this
->
users_key
]
)
?
$_POST
[
$this
->
users_key
]
:
false
;
// Parse for nonce and API existence
if
(
is_array
(
$authy_data
)
&&
array_key_exists
(
'nonce'
,
$authy_data
)
&&
wp_verify_nonce
(
$authy_data
[
'nonce'
],
$this
->
users_key
.
'edit_own'
)
)
{
// Email address
$userdata
=
get_userdata
(
$user_id
);
if
(
is_object
(
$userdata
)
&&
!
is_wp_error
(
$userdata
)
)
$email
=
$userdata
->
data
->
user_email
;
else
$email
=
null
;
// Phone number
$phone
=
preg_replace
(
'#[^\d]#'
,
''
,
$authy_data
[
'phone'
]
);
$country_code
=
preg_replace
(
'#[^\d\+]#'
,
''
,
$authy_data
[
'country_code'
]
);
// Process information with Authy
$this
->
set_authy_data
(
$user_id
,
$email
,
$phone
,
$country_code
);
}
}
/**
*
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment