https://wiki.appstudio.dev/index.php?title=Current_user&feed=atom&action=history
Current user - Revision history
2024-03-29T05:28:21Z
Revision history for this page on the wiki
MediaWiki 1.41.0
https://wiki.appstudio.dev/index.php?title=Current_user&diff=11207&oldid=prev
Ghenne at 15:22, 25 February 2021
2021-02-25T15:22:22Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:22, 25 February 2021</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l9">Line 9:</td>
<td colspan="2" class="diff-lineno">Line 9:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''$volt.use.get'''(''callback'')</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''$volt.use.get'''(''callback'')</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <del style="font-weight: bold; text-decoration: none;">Volt </del>is complete (or fails).</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <ins style="font-weight: bold; text-decoration: none;">VoltServer </ins>is complete (or fails).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="JavaScript"></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="JavaScript"></div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l49">Line 49:</td>
<td colspan="2" class="diff-lineno">Line 49:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </syntaxhighlight></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </syntaxhighlight></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>What gets returned? <del style="font-weight: bold; text-decoration: none;">Here is what is in the initial release of Volt:</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>What gets returned?</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="json"></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="json"></div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l70">Line 70:</td>
<td colspan="2" class="diff-lineno">Line 70:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* ''data'' - object, required. An object with the user details to update.</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* ''data'' - object, required. An object with the user details to update.</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <del style="font-weight: bold; text-decoration: none;">Volt </del>is complete (or fails).</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <ins style="font-weight: bold; text-decoration: none;">VoltServer </ins>is complete (or fails).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The data object should be of the following form:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>The data object should be of the following form:</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l129">Line 129:</td>
<td colspan="2" class="diff-lineno">Line 129:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''$volt.user.delete'''(''callback'')</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>'''$volt.user.delete'''(''callback'')</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <del style="font-weight: bold; text-decoration: none;">Volt </del>is complete (or fails).</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* ''callback'' - function(error, data), required. The function in your app to call when the request to <ins style="font-weight: bold; text-decoration: none;">VoltServer </ins>is complete (or fails).</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="JavaScript"></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> <syntaxhighlight lang="JavaScript"></div></td></tr>
<!-- diff cache key nsbasic_mediawiki1348787612:diff:1.41:old-9243:rev-11207:php=table -->
</table>
Ghenne
https://wiki.appstudio.dev/index.php?title=Current_user&diff=9243&oldid=prev
Sarah: Instructions for creating and working with the current user
2017-05-26T23:23:23Z
<p>Instructions for creating and working with the current user</p>
<p><b>New page</b></p><div>Here are some functions for managing the users of your app. You'll need to [[first_app|initialize your app]], after which you can get the information for the logged in user, modify it or delete it.<br />
<br />
== Get User information ==<br />
<br />
You can get information on the currently logged on user with the <code>$volt.user.get()</code> function.<br />
<br />
The syntax of the function is:<br />
<br />
'''$volt.use.get'''(''callback'')<br />
<br />
* ''callback'' - function(error, data), required. The function in your app to call when the request to Volt is complete (or fails).<br />
<br />
<syntaxhighlight lang="JavaScript"><br />
var user;<br />
<br />
butGetUser.onclick = function() {<br />
$volt.user.get(getUserCallback);<br />
}<br />
<br />
function getUserCallback(error, data) {<br />
if (error) {<br />
if (!data) {<br />
data = { message: 'Network Error' };<br />
}<br />
alert(data.message);<br />
user = null;<br />
} else {<br />
user = data;<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="basic"><br />
Dim user<br />
<br />
Function butGetUser_onclick()<br />
$volt.user.get(getUserCallback)<br />
End Function<br />
<br />
Function getUserCallback(error, data)<br />
If error Then<br />
If (!data) Then data = { message: "Network Error" }<br />
alert(data.message)<br />
user = null<br />
Else<br />
user = data<br />
End If<br />
End Function<br />
</syntaxhighlight><br />
<br />
What gets returned? Here is what is in the initial release of Volt:<br />
<br />
<syntaxhighlight lang="json"><br />
{<br />
"id": "7PQipR",<br />
"email": "support@nsbasic.com",<br />
"confirmed": true,<br />
"first_name": "John",<br />
"last_name": "Smith"<br />
}<br />
</syntaxhighlight><br />
<br />
== Modify User information ==<br />
<br />
You can change information for the currently logged on user with the <code>$volt.user.update()</code> function.<br />
<br />
The syntax of the function is:<br />
<br />
'''$volt.user.get'''(''data'', ''callback'')<br />
<br />
* ''data'' - object, required. An object with the user details to update.<br />
* ''callback'' - function(error, data), required. The function in your app to call when the request to Volt is complete (or fails).<br />
<br />
The data object should be of the following form:<br />
<br />
<syntaxhighlight lang="json"><br />
{<br />
"email": "new@email.com",<br />
"password": {<br />
"old": "myOldPassword",<br />
"new": "myNewPassword",<br />
"confirmation": "myNewPassword"<br />
},<br />
"first_name": "Alan",<br />
"last_name": "Turing"<br />
}<br />
</syntaxhighlight><br />
<br />
You can pass <code>email</code>, <code>password</code>, <code>first_name</code>, <code>last_name</code> or any combination thereof. Here's an example of changing the logged in user's email:<br />
<br />
<syntaxhighlight lang="JavaScript"><br />
butUpdateUser.onclick = function() {<br />
$volt.user.update({ email: inpNewEmail.value }, updateUserCallback);<br />
}<br />
<br />
function updateUserCallback(error, data) {<br />
if (error) {<br />
if (!data) {<br />
data = { message: 'Network Error' };<br />
}<br />
alert(data.message);<br />
} else {<br />
alert('User updated.');<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="basic"><br />
Function butUpdateUser_onclick()<br />
$volt.user.update({ email: inpNewEmail.value }, updateUserCallback)<br />
End Function<br />
<br />
Function getUserCallback(error, data)<br />
If error Then<br />
If (!data) Then data = { message: "Network Error" }<br />
alert(data.message)<br />
Else<br />
alert("User updated.")<br />
End If<br />
End Function<br />
</syntaxhighlight><br />
<br />
== Delete a User ==<br />
<br />
You can provide your users with a way to close/delete their accounts using the <code>$volt.user.delete()</code> function.<br />
<br />
The syntax of the function is:<br />
<br />
'''$volt.user.delete'''(''callback'')<br />
<br />
* ''callback'' - function(error, data), required. The function in your app to call when the request to Volt is complete (or fails).<br />
<br />
<syntaxhighlight lang="JavaScript"><br />
function deleteUser() {<br />
$volt.user.delete(deleteUserCallback);<br />
}<br />
<br />
function deleteUserCallback(error, data) {<br />
if (error) {<br />
if (!data) {<br />
data = { message: 'Network Error' };<br />
}<br />
alert(data.message);<br />
} else {<br />
alert('User deleted.');<br />
}<br />
}<br />
</syntaxhighlight><br />
<br />
<syntaxhighlight lang="basic"><br />
Function deleteUser()<br />
$volt.user.delete(deleteUserCallback)<br />
End Function<br />
<br />
Function deleteUserCallback(error, data)<br />
If error Then<br />
If (!data) Then data = { message: "Network Error" }<br />
MsgBox data.message<br />
Else<br />
MsgBox "User Deleted"<br />
End If<br />
End Function<br />
</syntaxhighlight><br />
<br />
== Reference ==<br />
<br />
* JavaScript API<br />
* [https://docs.voltcloud.io/client/$volt.user.html#.get https://docs.voltcloud.io/client/$volt.user.html#.get]<br />
* [https://docs.voltcloud.io/client/$volt.user.html#.update https://docs.voltcloud.io/client/$volt.user.html#.update]<br />
* [https://docs.voltcloud.io/client/$volt.user.html#.delete https://docs.voltcloud.io/client/$volt.user.html#.delete]<br />
* REST API<br />
* [https://docs.voltcloud.io/api/#users-current-user-get https://docs.voltcloud.io/api/#users-current-user-get]<br />
* [https://docs.voltcloud.io/api/#users-current-user-put https://docs.voltcloud.io/api/#users-current-user-put]<br />
* [https://docs.voltcloud.io/api/#users-current-user-delete https://docs.voltcloud.io/api/#users-current-user-delete]</div>
Sarah