1
0
Fork 0
mirror of synced 2024-06-09 22:34:46 +12:00

feat: update console sdk and ui to use new email auth

This commit is contained in:
Torsten Dittmann 2022-06-14 12:39:53 +02:00
parent 1f91e5328a
commit 861023abcf
13 changed files with 424 additions and 179 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -19,17 +19,17 @@ $root = ($this->getParam('root') !== 'disabled');
<p>Login using email and password</p>
<form name="account.createSession"
<form name="account.createEmailSession"
data-analytics
data-analytics-activity
data-analytics-event="submit"
data-analytics-category="home"
data-analytics-label="Create Account Session"
data-service="account.createSession"
data-service="account.createEmailSession"
data-scope="console"
data-event="submit"
data-success="trigger,hide,redirect"
data-success-param-trigger-events="account.createSession"
data-success-param-trigger-events="account.createEmailSession"
data-success-param-redirect-url="/console"
data-failure="alert"
data-failure-param-alert-text="Login failed. Please check your credentials."

216
composer.lock generated
View file

@ -481,16 +481,16 @@
},
{
"name": "guzzlehttp/guzzle",
"version": "7.4.3",
"version": "7.4.4",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "74a8602c6faec9ef74b7a9391ac82c5e65b1cdab"
"reference": "e3ff079b22820c2029d4c2a87796b6a0b8716ad8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/74a8602c6faec9ef74b7a9391ac82c5e65b1cdab",
"reference": "74a8602c6faec9ef74b7a9391ac82c5e65b1cdab",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/e3ff079b22820c2029d4c2a87796b6a0b8716ad8",
"reference": "e3ff079b22820c2029d4c2a87796b6a0b8716ad8",
"shasum": ""
},
"require": {
@ -585,7 +585,7 @@
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.4.3"
"source": "https://github.com/guzzle/guzzle/tree/7.4.4"
},
"funding": [
{
@ -601,7 +601,7 @@
"type": "tidelift"
}
],
"time": "2022-05-25T13:24:33+00:00"
"time": "2022-06-09T21:39:15+00:00"
},
{
"name": "guzzlehttp/promises",
@ -689,16 +689,16 @@
},
{
"name": "guzzlehttp/psr7",
"version": "2.2.1",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "c94a94f120803a18554c1805ef2e539f8285f9a2"
"reference": "83260bb50b8fc753c72d14dc1621a2dac31877ee"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/c94a94f120803a18554c1805ef2e539f8285f9a2",
"reference": "c94a94f120803a18554c1805ef2e539f8285f9a2",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/83260bb50b8fc753c72d14dc1621a2dac31877ee",
"reference": "83260bb50b8fc753c72d14dc1621a2dac31877ee",
"shasum": ""
},
"require": {
@ -722,7 +722,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
"dev-master": "2.3-dev"
}
},
"autoload": {
@ -784,7 +784,7 @@
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.2.1"
"source": "https://github.com/guzzle/psr7/tree/2.3.0"
},
"funding": [
{
@ -800,7 +800,7 @@
"type": "tidelift"
}
],
"time": "2022-03-20T21:55:58+00:00"
"time": "2022-06-09T08:26:02+00:00"
},
{
"name": "influxdb/influxdb-php",
@ -1583,16 +1583,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.6.2",
"version": "3.7.0",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a"
"reference": "a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a",
"reference": "5e4e71592f69da17871dba6e80dd51bce74a351a",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563",
"reference": "a2cd51b45bcaef9c1f2a4bda48f2dd2fa2b95563",
"shasum": ""
},
"require": {
@ -1635,7 +1635,7 @@
"source": "https://github.com/squizlabs/PHP_CodeSniffer",
"wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
},
"time": "2021-12-12T21:44:58+00:00"
"time": "2022-06-13T06:31:38+00:00"
},
{
"name": "symfony/deprecation-contracts",
@ -1704,88 +1704,6 @@
],
"time": "2022-02-25T11:15:52+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.26.0",
@ -2905,21 +2823,21 @@
},
{
"name": "webmozart/assert",
"version": "1.10.0",
"version": "1.11.0",
"source": {
"type": "git",
"url": "https://github.com/webmozarts/assert.git",
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25"
"reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25",
"reference": "6964c76c7804814a842473e0c8fd15bab0f18e25",
"url": "https://api.github.com/repos/webmozarts/assert/zipball/11cb2199493b2f8a3b53e7f19068fc6aac760991",
"reference": "11cb2199493b2f8a3b53e7f19068fc6aac760991",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"symfony/polyfill-ctype": "^1.8"
"ext-ctype": "*",
"php": "^7.2 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<0.12.20",
@ -2957,9 +2875,9 @@
],
"support": {
"issues": "https://github.com/webmozarts/assert/issues",
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
"source": "https://github.com/webmozarts/assert/tree/1.11.0"
},
"time": "2021-03-09T10:59:23+00:00"
"time": "2022-06-03T18:03:27+00:00"
}
],
"packages-dev": [
@ -5086,6 +5004,88 @@
],
"time": "2022-04-18T20:38:04+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-ctype": "*"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Gert de Pagter",
"email": "BackEndTea@gmail.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.26.0",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -493,7 +493,7 @@ function handler2(){}
handler2.inline=(el,{expression},{cleanup:cleanup2})=>{let root=closestRoot(el);if(!root._x_refs)
root._x_refs={};root._x_refs[expression]=el;cleanup2(()=>delete root._x_refs[expression]);};directive("ref",handler2);directive("if",(el,{expression},{effect:effect3,cleanup:cleanup2})=>{let evaluate2=evaluateLater(el,expression);let show=()=>{if(el._x_currentIfEl)
return el._x_currentIfEl;let clone2=el.content.cloneNode(true).firstElementChild;addScopeToNode(clone2,{},el);mutateDom(()=>{el.after(clone2);initTree(clone2);});el._x_currentIfEl=clone2;el._x_undoIf=()=>{clone2.remove();delete el._x_currentIfEl;};return clone2;};let hide=()=>{if(!el._x_undoIf)
return;el._x_undoIf();delete el._x_undoIf;};effect3(()=>evaluate2((value)=>{value?show():hide();}));cleanup2(()=>el._x_undoIf&&el._x_undoIf());});mapAttributes(startingWith("@",into(prefix("on:"))));directive("on",skipDuringClone((el,{value,modifiers,expression},{cleanup:cleanup2})=>{let evaluate2=expression?evaluateLater(el,expression):()=>{};let removeListener=on(el,value,modifiers,(e)=>{evaluate2(()=>{},{scope:{$event:e},params:[e]});});cleanup2(()=>removeListener());}));alpine_default.setEvaluator(normalEvaluator);alpine_default.setReactivityEngine({reactive:reactive2,effect:effect2,release:stop,raw:toRaw});var src_default=alpine_default;window.Alpine=src_default;queueMicrotask(()=>{src_default.start();});})();window.ls.error=function(){return function(error){window.console.error(error);if(window.location.pathname!=='/console'){window.location='/console';}};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("account.deleteSession",function(){window.location="/auth/signin";});document.addEventListener("account.create",function(){let container=window.ls.container;let form=container.get('serviceForm');let sdk=container.get('console');let promise=sdk.account.createSession(form.email,form.password);container.set("serviceForm",{},true,true);promise.then(function(){var subscribe=document.getElementById('newsletter').checked;if(subscribe){let alerts=container.get('alerts');let loaderId=alerts.add({text:'Loading...',class:""},0);fetch('https://appwrite.io/v1/newsletter/subscribe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({name:form.name,email:form.email,}),}).finally(function(){alerts.remove(loaderId);window.location='/console';});}else{window.location='/console';}},function(error){window.location='/auth/signup?failure=1';});});window.addEventListener("load",async()=>{const bars=12;const realtime=window.ls.container.get('realtime');const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));let current={};window.ls.container.get('console').subscribe(['project','console'],response=>{if(response.events.includes('stats.connections')){for(let project in response.payload){current[project]=response.payload[project]??0;}
return;el._x_undoIf();delete el._x_undoIf;};effect3(()=>evaluate2((value)=>{value?show():hide();}));cleanup2(()=>el._x_undoIf&&el._x_undoIf());});mapAttributes(startingWith("@",into(prefix("on:"))));directive("on",skipDuringClone((el,{value,modifiers,expression},{cleanup:cleanup2})=>{let evaluate2=expression?evaluateLater(el,expression):()=>{};let removeListener=on(el,value,modifiers,(e)=>{evaluate2(()=>{},{scope:{$event:e},params:[e]});});cleanup2(()=>removeListener());}));alpine_default.setEvaluator(normalEvaluator);alpine_default.setReactivityEngine({reactive:reactive2,effect:effect2,release:stop,raw:toRaw});var src_default=alpine_default;window.Alpine=src_default;queueMicrotask(()=>{src_default.start();});})();window.ls.error=function(){return function(error){window.console.error(error);if(window.location.pathname!=='/console'){window.location='/console';}};};window.addEventListener("error",function(event){console.error("ERROR-EVENT:",event.error.message,event.error.stack);});document.addEventListener("account.deleteSession",function(){window.location="/auth/signin";});document.addEventListener("account.create",function(){let container=window.ls.container;let form=container.get('serviceForm');let sdk=container.get('console');let promise=sdk.account.createEmailSession(form.email,form.password);container.set("serviceForm",{},true,true);promise.then(function(){var subscribe=document.getElementById('newsletter').checked;if(subscribe){let alerts=container.get('alerts');let loaderId=alerts.add({text:'Loading...',class:""},0);fetch('https://appwrite.io/v1/newsletter/subscribe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({name:form.name,email:form.email,}),}).finally(function(){alerts.remove(loaderId);window.location='/console';});}else{window.location='/console';}},function(error){window.location='/auth/signup?failure=1';});});window.addEventListener("load",async()=>{const bars=12;const realtime=window.ls.container.get('realtime');const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));let current={};window.ls.container.get('console').subscribe(['project','console'],response=>{if(response.events.includes('stats.connections')){for(let project in response.payload){current[project]=response.payload[project]??0;}
return;}
if(response.events.includes('collections.*.attributes.*')){document.dispatchEvent(new CustomEvent('database.createAttribute'));return;}
if(response.events.includes('collections.*.indexes.*')){document.dispatchEvent(new CustomEvent('database.createIndex'));return;}

View file

@ -375,6 +375,35 @@
'content-type': 'application/json',
}, payload);
}),
/**
* Update Account Phone
*
*
* @param {string} number
* @param {string} password
* @throws {AppwriteException}
* @returns {Promise}
*/
updatePhone: (number, password) => __awaiter(this, void 0, void 0, function* () {
if (typeof number === 'undefined') {
throw new AppwriteException('Missing required parameter: "number"');
}
if (typeof password === 'undefined') {
throw new AppwriteException('Missing required parameter: "password"');
}
let path = '/account/phone';
let payload = {};
if (typeof number !== 'undefined') {
payload['number'] = number;
}
if (typeof password !== 'undefined') {
payload['password'] = password;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Get Account Preferences
*
@ -522,37 +551,6 @@
'content-type': 'application/json',
}, payload);
}),
/**
* Create Account Session
*
* Allow the user to login into their account by providing a valid email and
* password combination. This route will create a new session for the user.
*
* @param {string} email
* @param {string} password
* @throws {AppwriteException}
* @returns {Promise}
*/
createSession: (email, password) => __awaiter(this, void 0, void 0, function* () {
if (typeof email === 'undefined') {
throw new AppwriteException('Missing required parameter: "email"');
}
if (typeof password === 'undefined') {
throw new AppwriteException('Missing required parameter: "password"');
}
let path = '/account/sessions';
let payload = {};
if (typeof email !== 'undefined') {
payload['email'] = email;
}
if (typeof password !== 'undefined') {
payload['password'] = password;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Delete All Account Sessions
*
@ -591,6 +589,37 @@
'content-type': 'application/json',
}, payload);
}),
/**
* Create Account Session with Email
*
* Allow the user to login into their account by providing a valid email and
* password combination. This route will create a new session for the user.
*
* @param {string} email
* @param {string} password
* @throws {AppwriteException}
* @returns {Promise}
*/
createEmailSession: (email, password) => __awaiter(this, void 0, void 0, function* () {
if (typeof email === 'undefined') {
throw new AppwriteException('Missing required parameter: "email"');
}
if (typeof password === 'undefined') {
throw new AppwriteException('Missing required parameter: "password"');
}
let path = '/account/sessions/email';
let payload = {};
if (typeof email !== 'undefined') {
payload['email'] = email;
}
if (typeof password !== 'undefined') {
payload['password'] = password;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Magic URL session
*
@ -724,6 +753,64 @@
return uri;
}
},
/**
* Create Phone session
*
*
* @param {string} userId
* @param {string} number
* @throws {AppwriteException}
* @returns {Promise}
*/
createPhoneSession: (userId, number) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof number === 'undefined') {
throw new AppwriteException('Missing required parameter: "number"');
}
let path = '/account/sessions/phone';
let payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
}
if (typeof number !== 'undefined') {
payload['number'] = number;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Phone session (confirmation)
*
*
* @param {string} userId
* @param {string} secret
* @throws {AppwriteException}
* @returns {Promise}
*/
updatePhoneSession: (userId, secret) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof secret === 'undefined') {
throw new AppwriteException('Missing required parameter: "secret"');
}
let path = '/account/sessions/phone';
let payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
}
if (typeof secret !== 'undefined') {
payload['secret'] = secret;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('put', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Get Session By ID
*
@ -877,6 +964,50 @@
return yield this.call('put', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Phone Verification
*
*
* @throws {AppwriteException}
* @returns {Promise}
*/
createPhoneVerification: () => __awaiter(this, void 0, void 0, function* () {
let path = '/account/verification/phone';
let payload = {};
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Create Phone Verification (confirmation)
*
*
* @param {string} userId
* @param {string} secret
* @throws {AppwriteException}
* @returns {Promise}
*/
updatePhoneVerification: (userId, secret) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof secret === 'undefined') {
throw new AppwriteException('Missing required parameter: "secret"');
}
let path = '/account/verification/phone';
let payload = {};
if (typeof userId !== 'undefined') {
payload['userId'] = userId;
}
if (typeof secret !== 'undefined') {
payload['secret'] = secret;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('put', uri, {
'content-type': 'application/json',
}, payload);
})
};
this.avatars = {
@ -2488,6 +2619,9 @@
payload['activate'] = activate;
}
const uri = new URL(this.config.endpoint + path);
if (!(code instanceof File)) {
throw new AppwriteException('Parameter "code" has to be a File.');
}
const size = code.size;
if (size <= Appwrite.CHUNK_SIZE) {
return yield this.call('post', uri, {
@ -3462,10 +3596,11 @@
* @param {string} projectId
* @param {string} name
* @param {string[]} scopes
* @param {number} expire
* @throws {AppwriteException}
* @returns {Promise}
*/
createKey: (projectId, name, scopes) => __awaiter(this, void 0, void 0, function* () {
createKey: (projectId, name, scopes, expire) => __awaiter(this, void 0, void 0, function* () {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}
@ -3483,6 +3618,9 @@
if (typeof scopes !== 'undefined') {
payload['scopes'] = scopes;
}
if (typeof expire !== 'undefined') {
payload['expire'] = expire;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('post', uri, {
'content-type': 'application/json',
@ -3519,10 +3657,11 @@
* @param {string} keyId
* @param {string} name
* @param {string[]} scopes
* @param {number} expire
* @throws {AppwriteException}
* @returns {Promise}
*/
updateKey: (projectId, keyId, name, scopes) => __awaiter(this, void 0, void 0, function* () {
updateKey: (projectId, keyId, name, scopes, expire) => __awaiter(this, void 0, void 0, function* () {
if (typeof projectId === 'undefined') {
throw new AppwriteException('Missing required parameter: "projectId"');
}
@ -3543,6 +3682,9 @@
if (typeof scopes !== 'undefined') {
payload['scopes'] = scopes;
}
if (typeof expire !== 'undefined') {
payload['expire'] = expire;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('put', uri, {
'content-type': 'application/json',
@ -4304,6 +4446,9 @@
payload['write'] = write;
}
const uri = new URL(this.config.endpoint + path);
if (!(file instanceof File)) {
throw new AppwriteException('Parameter "file" has to be a File.');
}
const size = file.size;
if (size <= Appwrite.CHUNK_SIZE) {
return yield this.call('post', uri, {
@ -5296,6 +5441,32 @@
'content-type': 'application/json',
}, payload);
}),
/**
* Update Phone
*
*
* @param {string} userId
* @param {string} number
* @throws {AppwriteException}
* @returns {Promise}
*/
updatePhone: (userId, number) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof number === 'undefined') {
throw new AppwriteException('Missing required parameter: "number"');
}
let path = '/users/{userId}/phone'.replace('{userId}', userId);
let payload = {};
if (typeof number !== 'undefined') {
payload['number'] = number;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Get User Preferences
*
@ -5463,6 +5634,32 @@
return yield this.call('patch', uri, {
'content-type': 'application/json',
}, payload);
}),
/**
* Update Phone Verification
*
*
* @param {string} userId
* @param {boolean} phoneVerification
* @throws {AppwriteException}
* @returns {Promise}
*/
updatePhoneVerification: (userId, phoneVerification) => __awaiter(this, void 0, void 0, function* () {
if (typeof userId === 'undefined') {
throw new AppwriteException('Missing required parameter: "userId"');
}
if (typeof phoneVerification === 'undefined') {
throw new AppwriteException('Missing required parameter: "phoneVerification"');
}
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
let payload = {};
if (typeof phoneVerification !== 'undefined') {
payload['phoneVerification'] = phoneVerification;
}
const uri = new URL(this.config.endpoint + path);
return yield this.call('patch', uri, {
'content-type': 'application/json',
}, payload);
})
};
}

View file

@ -23,7 +23,7 @@ document.addEventListener("account.create", function () {
let form = container.get('serviceForm');
let sdk = container.get('console');
let promise = sdk.account.createSession(form.email, form.password);
let promise = sdk.account.createEmailSession(form.email, form.password);
container.set("serviceForm", {}, true, true); // Remove sensitive data when not needed