Advertisement
lightningstalon

Neofriends Authorization (VB.NET)

Feb 4th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Collections
  2. Imports System.Collections.Generic
  3. Imports System.Text
  4. Imports System.Windows.Forms
  5. Imports Authorization
  6.  
  7. Public Partial Class frmMain
  8.     Inherits Form
  9.     Public Sub New()
  10.         InitializeComponent()
  11.     End Sub
  12.  
  13.     #Region "Authorization"
  14.  
  15.     Private Sub btnAuthorize_Click(sender As Object, e As EventArgs)
  16.         'Validate that user has entered correct information in textboxes.
  17.  
  18.         'Use NFAuth's constructor to your full advantage
  19.         Dim auth As New NFAuth(txtUsername.Text, txtPassword.Text, PROGRAM_ID, PROGRAM_NAME, Me, UpdateSub := AddressOf Auth_UpdateHandler, _
  20.             AuthorizedSub := AddressOf Auth_AuthorizedHandler, UnAuthorizedSub := AddressOf Auth_UnauthorizedHandler, ExceptionSub := AddressOf Auth_ExceptionHandler)
  21.  
  22.         'Settings can also be set like this:
  23.         auth.StatusLabel = lblStatus
  24.  
  25.         'Authorize asynchronously so it doesn't freeze the GUI
  26.         auth.AuthorizeASync()
  27.  
  28.         'Disable your authorize button
  29.         btnAuthorize.Enabled = False
  30.     End Sub
  31.  
  32.     Private Sub Auth_ExceptionHandler(ex As Exception)
  33.         'Handle the exception (stuff like Debug.Print() might help with debugging)
  34.     End Sub
  35.  
  36.     Private Sub Auth_AuthorizedHandler()
  37.         'Do something when they are authorized
  38.     End Sub
  39.  
  40.     Private Sub Auth_UnauthorizedHandler()
  41.         btnAuthorize.Enabled = True
  42.         'Do something for handling unauthorized.
  43.     End Sub
  44.  
  45.     Private Sub Auth_UpdateHandler()
  46.         'You can either require the user to update before using or just use the outdated version.
  47.     End Sub
  48.  
  49.     #End Region
  50. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement