Updated SDK examples
This commit is contained in:
parent
925eb5b2e7
commit
216d977083
|
@ -53,6 +53,9 @@ $collections = [
|
|||
'legalCity' => '',
|
||||
'legalAddress' => '',
|
||||
'legalTaxId' => '',
|
||||
'authWhitelistEmails' => explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_EMAILS', '')),
|
||||
'authWhitelistIPs' => explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_IPS', '')),
|
||||
'authWhitelistDomains' => explode(',', $request->getServer('_APP_CONSOLE_WHITELIST_DOMIANS', '')),
|
||||
],
|
||||
Database::SYSTEM_COLLECTION_COLLECTIONS => [
|
||||
'$collection' => Database::SYSTEM_COLLECTION_COLLECTIONS,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
|
||||
const VERSION = 'latest';
|
||||
const VERSION = '0.1.15';
|
||||
|
||||
return VERSION;
|
||||
|
|
|
@ -30,12 +30,30 @@ $utopia->post('/v1/auth/register')
|
|||
->label('abuse-limit', 10)
|
||||
->param('email', '', function () {return new Email();}, 'Account email')
|
||||
->param('password', '', function () {return new Password();}, 'User password')
|
||||
->param('name', '', function () {return new Text(100);}, 'User name', true)
|
||||
->param('redirect', '', function () use ($clients) {return new Host($clients);}, 'Confirmation page to redirect user after confirm token has been sent to user email')
|
||||
->param('success', null, function () use ($clients) {return new Host($clients);}, 'Redirect when registration succeed', true)
|
||||
->param('failure', null, function () use ($clients) {return new Host($clients);}, 'Redirect when registration failed', true)
|
||||
->param('name', '', function () {return new Text(100);}, 'User name', true)
|
||||
->param('success', null, function () use ($clients) {return new Host($clients);}, 'Redirect when registration succeed')
|
||||
->param('failure', null, function () use ($clients) {return new Host($clients);}, 'Redirect when registration failed')
|
||||
->action(
|
||||
function ($email, $password, $name, $redirect, $success, $failure) use ($request, $response, $register, $audit, $projectDB, $project, $webhook) {
|
||||
if('console' === $project->getUid()) {
|
||||
$whitlistEmails = $project->getAttribute('authWhitelistEmails');
|
||||
$whitlistIPs = $project->getAttribute('authWhitelistIPs');
|
||||
$whitlistDomains = $project->getAttribute('authWhitelistDomains');
|
||||
|
||||
if(!empty($whitlistEmails) && !in_array($email, $whitlistEmails)) {
|
||||
throw new Exception('Console access is restricted to specific emails', 401);
|
||||
}
|
||||
|
||||
if(!empty($whitlistIPs) && !in_array($request->getIP(), $whitlistIPs)) {
|
||||
throw new Exception('Console access is restricted to specific IPs', 401);
|
||||
}
|
||||
|
||||
if(!empty($whitlistDomains) && !in_array(substr(strrchr($email, "@"), 1), $whitlistDomains)) {
|
||||
throw new Exception('Console access is restricted to specific Domains', 401);
|
||||
}
|
||||
}
|
||||
|
||||
$profile = $projectDB->getCollection([ // Get user by email address
|
||||
'limit' => 1,
|
||||
'first' => true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# [Appwrite SDK for Ruby](https://appwrite.io) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Appwrite%20is%20a%20backend%20as%20a%20service%20for%20building%20web%20or%20mobile%20apps&url=http%3A%2F%2Fappwrite.io&via=appwrite_io&hashtags=JS%2Cjavascript%2Creactjs%2Cangular%2Cios%2Candroid)
|
||||
|
||||
![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-0.1.15-blue.svg?v=1)
|
||||
![Version](https://img.shields.io/badge/api%20version-latest-blue.svg?v=1)
|
||||
|
||||
**WORK IN PROGRESS - NOT READY FOR USAGE - Want to help us improve this client SDK? Send a pull request to Appwrite [SDK generator repository](https://github.com/appwrite/sdk-generator).**
|
||||
|
||||
|
@ -11,7 +11,7 @@ Appwrite backend as a service cuts up to 70% of the time and costs required for
|
|||
|
||||
![Appwrite](https://appwrite.io/images/github.png)
|
||||
|
||||
**API Version: 0.1.15**
|
||||
**API Version: latest**
|
||||
|
||||
## Installation
|
||||
|
||||
|
|
|
@ -89,14 +89,14 @@ module Appwrite
|
|||
}, params);
|
||||
end
|
||||
|
||||
def register(email:, password:, redirect:, success:, failure:, name: '')
|
||||
def register(email:, password:, redirect:, name: '', success: '', failure: '')
|
||||
path = '/auth/register'
|
||||
|
||||
params = {
|
||||
'email': email,
|
||||
'password': password,
|
||||
'redirect': redirect,
|
||||
'name': name,
|
||||
'redirect': redirect,
|
||||
'success': success,
|
||||
'failure': failure
|
||||
}
|
||||
|
|
8
composer.lock
generated
8
composer.lock
generated
|
@ -57,12 +57,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/appwrite/sdk-generator.git",
|
||||
"reference": "f3df64fba00218efc3fe02061359ad48ea939524"
|
||||
"reference": "609c832bef763adfc64919574e866ac527515000"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/f3df64fba00218efc3fe02061359ad48ea939524",
|
||||
"reference": "f3df64fba00218efc3fe02061359ad48ea939524",
|
||||
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/609c832bef763adfc64919574e866ac527515000",
|
||||
"reference": "609c832bef763adfc64919574e866ac527515000",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -94,7 +94,7 @@
|
|||
}
|
||||
],
|
||||
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
|
||||
"time": "2019-09-11 21:05:08"
|
||||
"time": "2019-09-12 15:56:58"
|
||||
},
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
|
|
|
@ -32,6 +32,9 @@ services:
|
|||
- _APP_INFLUXDB_PORT=8086
|
||||
- _APP_STATSD_HOST=telegraf
|
||||
- _APP_STATSD_PORT=8125
|
||||
- _APP_CONSOLE_WHITELIST_EMAILS=eldad.fux@example.com,eldad@example.io
|
||||
- _APP_CONSOLE_WHITELIST_IPS=192.1.1.100
|
||||
- _APP_CONSOLE_WHITELIST_DOMAINS=appwrite.io,example.com
|
||||
|
||||
mariadb:
|
||||
image: appwrite/mariadb:1.0.0 # fix issues when upgrading using: mysql_upgrade -u root -p
|
||||
|
|
Loading…
Reference in a new issue