Difference between revisions of "OpenIdLogin class"

From Catglobe Wiki
Jump to: navigation, search
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{CGscriptClass_Template
 
{{CGscriptClass_Template
 
|Name=<nowiki>OpenIdLogin</nowiki>
 
|Name=<nowiki>OpenIdLogin</nowiki>
|Description=<nowiki>Respresents an association between a user and an openId identifier. This will allow the user to login by specifying the identifier (or the short version) with an openid=xxx url parameter on any link.</nowiki>
+
|Description=<nowiki>Represents an association between a user and an openId identifier. This will allow the user to login by specifying the identifier (or the short version) with an openid=xxx url parameter on any link.</nowiki>
|Constructors=
+
|InheritsFrom=object|Constructors=
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=string|Name=<nowiki>claimedIdentifier</nowiki>|Description=<nowiki>The identifier (url) to lookup.</nowiki>}}
+
{{CGscriptParameters_Template|Type=string|Name=<nowiki>claimedIdentifier</nowiki>|Description=<nowiki>The identifier (url) too lookup.</nowiki>}}
 
|Description=<nowiki>Fetch an existing association from the identifier.</nowiki>}}
 
|Description=<nowiki>Fetch an existing association from the identifier.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=number|Name=<nowiki>userResourceId</nowiki>|Description=<nowiki>Resource Id of the user to associate an openId with.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>claimedIdentifier</nowiki>|Description=<nowiki>The identifier (url) too create with. It must be unique across all users.</nowiki>}}
+
{{CGscriptParameters_Template|Type=int|Name=<nowiki>userResourceId</nowiki>|Description=<nowiki>Resource Id of the user to associate an openId with.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>claimedIdentifier</nowiki>|Description=<nowiki>The identifier (url) too create with. It must be unique across all users.</nowiki>}}
 
|Description=<nowiki>Create a new association between a user and an identifier.</nowiki>}}
 
|Description=<nowiki>Create a new association between a user and an identifier.</nowiki>}}
 
{{CGscriptConstructors_Template|Parameters=
 
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=number|Name=<nowiki>userResourceId</nowiki>|Description=<nowiki>Resource Id of the user to associate an openId with.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>site</nowiki>|Description=<nowiki>The site name of the foreign site. E.g. cg.catglobe.com</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>username</nowiki>|Description=<nowiki>The username on the foreign site</nowiki>}}
+
{{CGscriptParameters_Template|Type=int|Name=<nowiki>userResourceId</nowiki>|Description=<nowiki>Resource Id of the user to associate an openId with.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>site</nowiki>|Description=<nowiki>The site name of the foreign site. E.g. cg.catglobe.com</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>username</nowiki>|Description=<nowiki>The username on the foreign site</nowiki>}}
 
|Description=<nowiki>Create a new association between a user and an identifier on a catglobe site.</nowiki>}}
 
|Description=<nowiki>Create a new association between a user and an identifier on a catglobe site.</nowiki>}}
 
|Methods=
 
|Methods=
 
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Destroy</nowiki>|Description=<nowiki>Remove the current association from the database.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Destroy</nowiki>|Description=<nowiki>Remove the current association from the database.</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save the current association to the Database. Requires admin group access</nowiki>}}
 
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Save</nowiki>|Description=<nowiki>Save the current association to the Database. Requires admin group access</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}}
+
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
 
|Properties=
 
|Properties=
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ClaimedIdentifier</nowiki>|HasGetter=1|Description=<nowiki>The identifier (url) of this association</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ClaimedIdentifier</nowiki>|HasGetter=1|Description=<nowiki>The identifier (url) of this association</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
 
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>UserResourceId</nowiki>|HasGetter=1|Description=<nowiki>Resource id of the user having this association</nowiki>}}
+
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>UserResourceId</nowiki>|HasGetter=1|Description=<nowiki>Resource id of the user having this association</nowiki>}}
 
}}
 
}}
  
 
===<span style="color: #DF8621;">Examples</span>===
 
===<span style="color: #DF8621;">Examples</span>===
 +
<source lang="javascript">
 +
/*
 +
ON ABC.CATGLOBE.COM SITE - CREATE OPENID LOGIN FOR CONSULTANTS OF CG SITE TO ACCESS TO ABC.CATGLOBE.COM SITE
 +
*/
 +
 +
number UserRID_ThisSite = 123456789;    // user: tungocman
 +
object OpenId;
 +
number i;
 +
 +
/* Specify the value for parameters */
 +
string Foreign_Site = "cg.catglobe.com";
 +
string UserName_ForeignSite = "man-cgsite"; 
 +
string Password_ForeignSite = "123456";
 +
number ForeignWorkflow_id = 111222333; // Workflow: List of usernames of members of a specific group
 +
 +
number GroupRID = 45384;            // Group: Consultants Group
 +
bool includeStatic = true;
 +
bool includeDynamic = true;
 +
 +
Dictionary Parameter = {"GroupRID":GroupRID, "includeStatic":includeStatic, "includeDynamic":includeDynamic};
 +
 +
RemoteWorkflowCall wfc = new RemoteWorkflowCall(ForeignWorkflow_id, UserName_ForeignSite, Password_ForeignSite, {Parameter});
 +
array GroupMemberNames = wfc.Call(Foreign_Site);
 +
print(GroupMemberNames);
 +
print(GroupMemberNames.Count);
 +
 +
for(i = 0; i < GroupMemberNames.Count; i = i+1)
 +
{
 +
OpenId = new OpenIdLogin(UserRID_ThisSite, Foreign_Site, GroupMemberNames[i]);
 +
OpenId.Save();
 +
print(OpenId.ClaimedIdentifier);
 +
}
 +
 +
 +
=====================================================
 +
/*
 +
 +
FOREIGN WORKFLOW ON CG.CATGLOBE.COM SITE - WORKFLOW RETURN A ARRAY OF USERNAMES OF MEMBERS OF A SPECIFIC GROUP
 +
*/
 +
 +
array Paras = Workflow_getParameters();
 +
 +
number GroupRID;
 +
bool includeStatic;
 +
bool includeDynamic;
 +
 +
array Result;                          // an array of usernames of members of a specific group
 +
array GroupMembers;
 +
array UserObject;
 +
number i;
 +
 +
GroupRID = Paras[0]["GroupRID"];
 +
includeStatic = Paras[0]["includeStatic"];
 +
includeDynamic = Paras[0]["includeDynamic"];
 +
 +
GroupMembers = Group_getMembers(GroupRID, false, false, includeStatic, includeDynamic);
 +
 +
for(i = 0; i < GroupMembers.Count; i = i+1)
 +
{
 +
UserObject = User_getUserByResourceId(GroupMembers[i]);
 +
Result.Add(UserObject[USER_NAME]);
 +
}
 +
return Result;
 +
</source>

Latest revision as of 06:03, 2 July 2020

OpenIdLogin



Represents an association between a user and an openId identifier. This will allow the user to login by specifying the identifier (or the short version) with an openid=xxx url parameter on any link.

Parent class

Inherits from object

Constructors

  • (string claimedIdentifier "The identifier (url) too lookup.") - Fetch an existing association from the identifier.
  • (int userResourceId "Resource Id of the user to associate an openId with.", string claimedIdentifier "The identifier (url) too create with. It must be unique across all users.") - Create a new association between a user and an identifier.
  • (int userResourceId "Resource Id of the user to associate an openId with.", string site "The site name of the foreign site. E.g. cg.catglobe.com", string username "The username on the foreign site") - Create a new association between a user and an identifier on a catglobe site.

Methods

  • Empty Destroy() - Remove the current association from the database.
  • Empty Save() - Save the current association to the Database. Requires admin group access
  • (From object) string ToString() - The string representation of the object.

Properties

  • string ClaimedIdentifier { get; } - The identifier (url) of this association
  • string ObjectTypeName { get; } - The name of the type of object.
  • (From object) TypeInformation TypeInformation { get; } - Get information about this class.
  • int UserResourceId { get; } - Resource id of the user having this association


Examples

/* 
	ON ABC.CATGLOBE.COM SITE - CREATE OPENID LOGIN FOR CONSULTANTS OF CG SITE TO ACCESS TO ABC.CATGLOBE.COM SITE
*/

number UserRID_ThisSite = 123456789;    		// user: tungocman
object OpenId;
number i;

/* Specify the value for parameters */
string Foreign_Site = "cg.catglobe.com";
string UserName_ForeignSite = "man-cgsite";   
string Password_ForeignSite = "123456";
number ForeignWorkflow_id = 111222333; 			// Workflow: List of usernames of members of a specific group

number GroupRID = 45384;     			        // Group: Consultants Group
bool includeStatic = true;
bool includeDynamic = true;

Dictionary Parameter = {"GroupRID":GroupRID, "includeStatic":includeStatic, "includeDynamic":includeDynamic};

RemoteWorkflowCall wfc = new RemoteWorkflowCall(ForeignWorkflow_id, UserName_ForeignSite, Password_ForeignSite, {Parameter});
array GroupMemberNames = wfc.Call(Foreign_Site);
print(GroupMemberNames);
print(GroupMemberNames.Count);

for(i = 0; i < GroupMemberNames.Count; i = i+1)
{
	OpenId = new OpenIdLogin(UserRID_ThisSite, Foreign_Site, GroupMemberNames[i]);
	OpenId.Save();
	print(OpenId.ClaimedIdentifier);
}


=====================================================
/* 
	
	FOREIGN WORKFLOW ON CG.CATGLOBE.COM SITE - WORKFLOW RETURN A ARRAY OF USERNAMES OF MEMBERS OF A SPECIFIC GROUP
*/

array Paras = Workflow_getParameters();

number GroupRID;
bool includeStatic;
bool includeDynamic;

array Result;  			                        // an array of usernames of members of a specific group
array GroupMembers;
array UserObject;
number i;

GroupRID = Paras[0]["GroupRID"];
includeStatic = Paras[0]["includeStatic"];
includeDynamic = Paras[0]["includeDynamic"];

GroupMembers = Group_getMembers(GroupRID, false, false, includeStatic, includeDynamic);

for(i = 0; i < GroupMembers.Count; i = i+1)
{
	UserObject = User_getUserByResourceId(GroupMembers[i]);
	Result.Add(UserObject[USER_NAME]);
}
return Result;