How to register users from register

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
 
(13 intermediate revisions by one user not shown)
Line 1: Line 1:
Supose that you have this scenario you want to register users from a database let's say PostgreSQL.
+
Suppose that you have this scenario: you want to register users from a database using PostgreSQL.
  
=== Create database===
+
===Startup configuration file===
  
After creating your database with the tables that you need (here is an example of [[Register_Database_Schema|a database schema]]), you have to tell Yate what database to use.
+
The main Yate startup configuration is stored in the file yate.conf.
  
=== Database connection data in Yate===
+
Please notice that "yate.conf" under Windows has to be named "yate-service.conf" if you are running it as a service or "yate-console.conf" while running the console version.
 +
In other words it has to match the executable file name or the file would not be loaded and default configuration will be applied.
  
==== Set the name of the database====
+
Note: By default in Yate all modules are loaded at startup. By setting parameter '''modload=no''' in section [default], you have to enable modules by hand to load them.
 +
This is done in section [modules] using parameter that contains the name of the module point yate (e.g ''pgsqldb.yate=true'' for using module pgsqldb).
  
So write in [[register|register.conf]] the name of the database connection to use:
+
File "yate.conf" controls the loading of [[modules]] in Yate.
 +
In your yate.conf these modules should be enabled by hand, only if you set modload=disable:
  
 
  [default]
 
  [default]
  account=Database_Name
+
  modload=disable
 +
 +
[modules]
 +
;Module used to make the connection between Yate and the PostgreSQL database.
 +
pgsqldb.yate=true
 +
;Module used do authenticate, register, route users in the database. 
 +
register.yate=true
 +
 
 +
===Configure database in Yate ===
 +
 
 +
There are 3 steps to accomplish this task:
 +
# create your database with tables that you need for your configuration (here is an example of [[Register_Database_Schema|a database schema]]).
 +
# put the credentials of the database of the database created in Yate's configuration file: pgsqldb.conf).
 +
# 'tell' Yate which connection to use when users will be registered. This is done in register.conf file.
 +
 
  
 
==== Set the connection information of database====
 
==== Set the connection information of database====
  
And in PostgreSQL configuration file: pgsqldb.conf we have to set the connection data for this database in a section that will have the same name as the account:
+
In PostgreSQL configuration file: [[PostgreSQL|pgsqldb.conf]] we have to set the connection data for this database in a section that will have the same name as the account settled in register.conf:
  
  [Database_Name]
+
  [yateadmin]
  host=
+
  host=localhost
  database=
+
port=5432
  user=
+
  database=yateadmin
  password=
+
  user=postgres
 +
  password=secret
 
    
 
    
 
After "=" you have to write your connection information.
 
After "=" you have to write your connection information.
  
===Enable modules===
+
==== Set the name of the database====
  
Also, in your yate.conf these modules should be enabled by hand, if you set modload=disable
+
In module used is [[register|register.conf]], in section [default] the name of the database must be set:
  
  [modules]
+
  [default]
  ; This section should hold one line for each module whose loading behaviour
+
  account=yateadmin
;  is to be changed from the default specified by modload= in section [general]
+
 
  ; Each line has to be of the form:
+
===Register users ===
  ;  modulename.yate=boolean
+
 
  ; Note that modules can be located only in the module directory so no path
+
See an example of a [[Register_Database_Schema|database schema]] to keep the users data.
  ;  information should be specified
+
 
pgsqldb.yate=true
+
In [[Register|register.conf]] in section '''[general]''' the user.register must be enabled.
  register.yate=true
+
 
 +
  [general]
 +
  user.register=yes
 +
   
 +
  [user.register]
 +
  query=UPDATE users SET location='${data}',expires=CURRENT_TIMESTAMP + INTERVAL '${expires} s' WHERE username='${username}'
  
  
 
'''See also'''
 
'''See also'''
  
* [[Regfile]]
+
* [[Regfile|Regfile module]] - authenticate, register and route users from a file.
* [[MySQL]]
+
* [[Register|Register module]] - authenticate, register and route users from database.
 +
* [[PostgreSQL]]
 +
* [[Routing]]
 +
 
 +
[[Category:Registration]] [[Category:Database]] [[Category:Users]]

Latest revision as of 16:59, 31 October 2013

Suppose that you have this scenario: you want to register users from a database using PostgreSQL.

Contents

[edit] Startup configuration file

The main Yate startup configuration is stored in the file yate.conf.

Please notice that "yate.conf" under Windows has to be named "yate-service.conf" if you are running it as a service or "yate-console.conf" while running the console version.
In other words it has to match the executable file name or the file would not be loaded and default configuration will be applied.
Note: By default in Yate all modules are loaded at startup. By setting parameter modload=no in section [default], you have to enable modules by hand to load them.
This is done in section [modules] using parameter that contains the name of the module point yate (e.g pgsqldb.yate=true for using module pgsqldb).

File "yate.conf" controls the loading of modules in Yate. In your yate.conf these modules should be enabled by hand, only if you set modload=disable:

[default]
modload=disable

[modules]
;Module used to make the connection between Yate and the PostgreSQL database.
pgsqldb.yate=true 
;Module used do authenticate, register, route users in the database.  
register.yate=true

[edit] Configure database in Yate

There are 3 steps to accomplish this task:

  1. create your database with tables that you need for your configuration (here is an example of a database schema).
  2. put the credentials of the database of the database created in Yate's configuration file: pgsqldb.conf).
  3. 'tell' Yate which connection to use when users will be registered. This is done in register.conf file.


[edit] Set the connection information of database

In PostgreSQL configuration file: pgsqldb.conf we have to set the connection data for this database in a section that will have the same name as the account settled in register.conf:

[yateadmin]
host=localhost
port=5432
database=yateadmin
user=postgres
password=secret
  

After "=" you have to write your connection information.

[edit] Set the name of the database

In module used is register.conf, in section [default] the name of the database must be set:

[default]
account=yateadmin

[edit] Register users

See an example of a database schema to keep the users data.

In register.conf in section [general] the user.register must be enabled.

[general]
user.register=yes

[user.register]
query=UPDATE users SET location='${data}',expires=CURRENT_TIMESTAMP + INTERVAL '${expires} s' WHERE username='${username}'


See also

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers